www.techofnote.com
...Vec<_> = self
.cell_positions()
.iter()
.map(|pos| self.cell(pos))
.filter_map(|cell| match &cell.symbol {
Some(symbol) => match symbol {
Symbol::Square(colour) | Symbol::Sun(colour) => Some((colour, &cell.region)),
},
None => None,
})
.collect();
let square_regions: Vec<_> = self
.cell_positions()
.iter()
.map(|pos| self.cell(pos))
.filter_map(|cell| match...
Rust Walkthroughs
2022-09-07
~9 min read
insanitybit.github.io
...self.queue_url.clone()
};
match self.sqs_client.delete_message_batch(&req) {
Ok(res) => {
unimplemented!()
},
Err(e) => {
println!("Failed to deleted {} messages {}", msg_count ,e);
}
}
}
}
A message for communicating to it:
pub enum MessageDeleterMessage {
DeleteMessages {
receipts: Vec<(String, Instant)>,
},
}
A ‘route_msg’ function to destructure the message and pass it...
News & Blog Posts
2017-07-18
~9 min read
passcod.name
...U8) -> U8 {{
match n {{
\u{FFA0}0 => \u{FFA0}1,
\u{FFA0}1 => \u{FFA0}1,
_ => fibonacci(n - \u{FFA0}1) + fibonacci(n - \u{FFA0}2),
}}
}}
fn factorial(n: U12) -> U12 {{
match n {{
\u{FFA0}\u{FFA0}0 | \u{FFA0}\u{FFA0}1 => \u{FFA0}\u{FFA0}1,
_ => factorial(n...
Rust Walkthroughs
2021-10-06
~18 min read
andreabergia.com
...pub fn push(&mut self, string: &str)
-> Result<(), ClassPathParseError> { /* ... */ }
/// Attempts to resolve a class from the various entries.
/// Stops at the first entry that has a match or an error.
pub fn resolve(&self, class_name: &str)
-> Result<Option<Vec<u8>>, ClassLoadingError> { /* ... */ }
}
The implementation of ClassPath will simply iterate through...
Observations/Thoughts
2023-08-30
~12 min read
www.greyblake.com
...impl Drink {
fn kind(&self) -> DrinkKind {
match self {
Drink::TapWater -> DrinkKind::TapWater,
Drink::Coffee(..) -> DrinkKind::Coffee,
Drink::Tea { .. } -> DrinkKind::Tea
}
}
}
And ability to iterate over all variants of DrinkKind:
impl DrinkKind {
fn all() -> Vec<DrinkKind> {
use DrinkKind::*;
vec![TapWater, Coffee, Tea]
}
}
The problem with the solution
The solution above will...
Rust Walkthroughs
2023-08-09
~3 min read
aloso.github.io
...Expr,) -> Option<Value> { match (kind, eval(vars, expr)?) { (UnExprKind::Not, Value::Bool(b)) => { Some(Value::Bool(!b)) } (UnExprKind::Neg, Value::Num(n)) => { Some(Value::Num(-n)) } _ => None, }}fn eval_binary( kind: BinExprKind, vars: &Variables<'_>, lhs: Expr, rhs: Expr,) -> Option<Value> { match kind { BinExprKind::Add => { if let Value::Num(lhs) = eval...
Rust Walkthroughs
2021-04-14
~10 min read
www.sea-ql.org
...let res = Bakery::insert_many(std::iter::empty()) .on_empty_do_nothing() // <- you needed to add this, // otherwise insert empty [] would lead to error .exec(db) .await;assert!(matches!(res, Ok(TryInsertResult::Empty)));
After careful consideration, we made a number of changes in 2.0:
removed APIs (e.g. Insert...
Project/Tooling Updates
2025-09-24
~9 min read
lucumr.pocoo.org
...impl Enumerator {
fn query_len(&self) -> Option<usize> {
Some(match self {
Enumerator::Empty => 0,
Enumerator::Values(v) => v.len(),
Enumerator::Iter(i) => match i.size_hint() {
(a, Some(b)) if a == b => a,
_ => return None,
},
Enumerator::RevIter(i) => match i.size_hint() {
(a, Some(b)) if a == b => a,
_ => return...
Observations/Thoughts
2024-08-28
~16 min read
lupyuen.github.io
...false,
},
14:15,
)
(StackSlot refers to the values in the constants array)
Let’s match the two…
Yep Abstract Syntax Trees can get deeply nested, like this for loop…
(See the complete Abstract Syntax Tree)
But Abstract Syntax Trees are actually perfect for converting Rhai to uLisp.
Lisp is a...
Rust Walkthroughs
2021-09-08
~24 min read
erickt.github.io
...ip::SocketAddr) -> libc::c_int {
unsafe {
let fd = match libc::socket(libc::AF_INET, libc::SOCK_STREAM, 0) {
-1 => panic!(),
fd => fd,
};
let mut storage = mem::zeroed();
let len = addr_to_sockaddr(addr, &mut storage);
let addrp = &storage as *const _ as *const libc::sockaddr;
match libc::bind(fd, addrp, len...
Blog Posts
2014-11-24
~16 min read
bevyengine.org
...This means 100% of the donations we receive go toward furthering our mission.Donations to Bevy Foundation (including all past donations that occurred this year) are now tax-deductible in the United States.Many employers have donation-matching programs for 501(c)(3)s. It is worth checking to see...
Project/Tooling Updates
2024-09-25
~2 min read
blog.paulme.ng
...is_match, find, captures.
A few lines of changes from using Captures to Matches reduce the running time by 2s.
Using dynamic programming to trace the best path in Viterbi decoding
I have speech processing and natural language processing background so I am quite familiar with hidden markov model training...
News & Blog Posts
2019-07-02
~7 min read
www.afloat.boats
...returns a value), we can assign the values to `tile_repr`
// And then write the value to the format "stream"
let tile_repr = match self {
TileType::Empty => "Empty",
TileType::Red => "Player Red",
TileType::Black => "Player Black",
};
write!(f, "{tile_repr}")
}
}
Compiles without a hitch!
And the browser console now logs...
Rust Walkthroughs
2025-08-27
~7 min read
rust-analyzer.github.io
#11461 (first-contribution) filter generics in Extract struct from enum variant.
#11531 (first contribution) make fill_match_arms assist handle #[doc(hidden)] and #[non_exhaustive].
#11535 (first contribution) add install instructions for Kakoune and Helix.
#11524 (first contribution) state that only the latest stable toolchain is officially supported.
#11424 pass...
Project/Tooling Updates
2022-03-02
~1 min read
smallcultfollowing.com
...After that, I will turn to virtual dispatch, impls,
and matching, and show how they interact.The Rust enumI don’t know about you, but when I work with C++, I find that the
first thing that I miss is the Rust enum. Usually what happens is
that I start...
Notable Links
2015-05-18
~5 min read
matthewkmayer.github.io
...if let Some(matches) = matches.subcommand_matches("generate") {
let services_config_path = matches.value_of("services_config").unwrap();
let service_configs = ServiceConfig::load_all(services_config_path)
.expect("Unable to read services configuration file.");
let out_dir = Path::new(matches.value_of("out_dir").unwrap());
commands::generate::generate_services(service...
News & Blog Posts
2017-07-18
~10 min read
freemasen.com
...u8) -> Self {
match v {
1 => Self::Legacy,
2 => Self::WriteAheadLog,
_ => Self::Unknown(v),
}
}
}
Let's just check in on a few things here. First we are deriveing a few more items,
PartialEq and Eq allow for using the == operator with 2 FormatVersions while
the PartialOrd and Ord allow for the...
Rust Walkthroughs
2020-11-18
~14 min read
github.com
...The migration lint will be implemented as follows:
* Find method calls matching the name of one of the newly added traits' methods.
This can be done either by hardcoding these method names or by setting up some
kind of registry through the use of an attribute on the relevant traits...
RFC 3114
RFC
2021-02-16
~6 min read
xd009642.github.io
...Additionally, the first
inference time is by default quite long to match behaviour observed in
the wild.
There’s also, some likelihood of the inference panicking or failing
without a panic. Interfacing with neural network runtimes often involves an FFI
interface and GPUs. Both of these can cause issues for...
Observations/Thoughts
2024-12-04
~11 min read
deaddabe.fr
...Implementing global aliasing
The need is to be able to match both PascalCase and camelCase, while
keeping the field names in snake_case to cope with established Rust naming
conventions. I first tried to add support for multiple deserialize entries
with the following syntax:
#[serde(rename_all(deserialize = "PascalCase", deserialize...
Observations/Thoughts
2021-01-27
~5 min read