guillaumegomez.github.io
...and added ‘platform-specific’ section to sleep_ms to match sleep..
@jmdyck added a link to the second edition of The Book.
@steveklabnik fixed wording around sort guarantees.
@estebank taught diagnostics to highlight text and provided disambiguated syntax for candidates in E0034.
@APTy added docs and tests for join_multicast...
Other Weeklies from Rust Community
2017-01-17
~2 min read
rust-analyzer.github.io
...type mismatch with associated types.
#12427 fix VSCode config patching incorrectly patching some configs.
#12444 implement parsing of ? opt-out trait bounds.
#12467 fix Match to if-let assist for wildcard patterns.
#12470, #12472 avoid duplicating output channels when restarting the server.
#12471 restart the server instead of reloading the...
Project/Tooling Updates
2022-06-08
~1 min read
ryhl.io
...In the example above, we match on the enum inside a handle_message method on
the actor struct, but that isn't the only way to structure this. One could also
match on the enum in the run_my_actor function. Each branch in this match
could then call various...
Rust Walkthroughs
2021-02-17
~11 min read
www.redox-os.org
...The public key must match the
one installed on disk. The signature of the struct must verify against the
public key. If this is true, the hash and entry count are considered valid.
The entry metadata can now be downloaded to a temporary file. During the
download, the BLAKE3 hash...
News & Blog Posts
2020-03-17
~5 min read
mobiarch.wordpress.com
...fn make_dir(path: &str) -> std::io::Result<()> {
let err = match std::fs::create_dir(path) {
Ok(_) => return Ok(()),
Err(e) => e
};
match err.kind() {
ErrorKind::AlreadyExists => return Ok(()),
_ => {
println!("Failed to create directory: {}", path);
return Err(err);
}
};
}
getenv
Use std::env:var.
if let Ok(val) = std::env::var...
From the Blogosphere
2015-07-13
~2 min read
kerkour.com
...fn do_something() -> Result<(), Error> {
let user = get_user_opt().ok_or(Error::UserNotFound)?;
// do something
}
match
Then, of course, there is match:
fn do_something() -> Result<(), Error> {
let user = match get_user_opt() {
Some(user) => user,
None => return Err(Error::UserNotFound);
};
// do something
}
if let / let else
Even better...
Observations/Thoughts
2026-10-21
~7 min read
hirrolot.github.io
...for S<Lhs> is the induction step
(recursion case) – similar to how we did with pattern matching using
match. Likewise, as in the first example, the induction
works by reducing the first argument to Z:
<Lhs as Add<Rhs>>::Result works just like
add(next, rhs) – it invokes pattern matching...
Observations/Thoughts
2022-01-26
~30 min read
rust-lang-nursery.github.io
...badge]][cat-text-processing] | | Extract phone numbers from text | [![regex-badge]][regex] | [![cat-text-processing-badge]][cat-text-processing] | | Filter a log file by matching multiple regular expressions | [![regex-badge]][regex] | [![cat-text-processing-badge]][cat-text-processing] | Replace all occurrences of one text pattern with another pattern. | [![regex-badge...
The Rust Cookbook
Book
2024-01-01
~1 min read
felix-knorr.net
...So I needed to transform my handler
functions so that their return type matches. In Python I would've used a
decorator function for that:
def eat_error(f):
def inner(*args, **kwargs):
return some_transformation(f(*args, **kwargs))
return inner
And I knew that there was this one type...
Rust Walkthroughs
2022-10-19
~6 min read
www.rustydonkey.dev
...All the same numeric comparisons are supported here too!
Text Matching: This one is really cool! You can find text that:
is exactly a certain string
starts with a substring
ends with a substring
contains a substring
Hierarchy: You can now also filter directly by an item's class and...
Project/Tooling Updates
2025-10-29
~4 min read
arzg.github.io
...Let’s add a todo!() and comment out the rest so we can get on with running our tests:impl Expr {
// snip
pub(crate) fn eval(&self, env: &Env) -> Result<Val, String> {
match self {
Self::Number(Number(n)) => Ok(Val::Number(*n)),
Self::Operation { lhs, rhs, op } => {
todo!();
// let Number...
Learn More Rust
2020-10-14
~25 min read
adventures.michaelfbryan.com
...std::slice::Iter<'src, Operation>,
}
Turning TextObjectParser into an Iterator turned out to be pretty easy
thanks to pattern matching. I know ahead of time exactly which operations
I’m looking for and what their operands will be so each pattern can be its
own branch in a big match...
Rust Walkthroughs
2021-02-03
~13 min read
minikin.me
...Presence<T>) {
match update {
Presence::Absent => {}, // Field missing from JSON → no change
Presence::Null => *target = None, // Field is null in JSON → clear
Presence::Some(v) => *target = Some(v), // Field has value → set it
}
}
fn apply_patch(user: &mut User, patch: UserPatch) {
apply_field(&mut user.name, patch.name);
apply_field...
Rust Walkthroughs
2025-12-17
~7 min read
blog.jetbrains.com
...When the output is not what you expected, it can be hard to see how the input matches the macro definition and what code the macro produced.
The new interactive declarative macro tester shows you the code your macro input expands into, as well as how the input and output...
Project/Tooling Updates
2026-07-22
~4 min read
dev.to
...diesel::result::Error, context: &str) -> AppError {
AppError::new(
format!("{}: {}", context, err.to_string()).as_str(),
match err {
diesel::result::Error::DatabaseError(db_err, _) => {
match db_err {
diesel::result::DatabaseErrorKind::UniqueViolation => ErrorType::BadRequest,
_ => ErrorType::Internal,
}
}
diesel::result::Error::NotFound => ErrorType::NotFound,
// Here we can handle other cases if needed
_ => {
ErrorType::Internal...
Learn More Rust
2020-08-04
~20 min read
matthewkmayer.github.io
...database_instance_name.to_string(),
db_instance_class: "db.t2.micro".to_string(),
// name and login details should match `.env` in rusoto-rocket
master_user_password: Some("TotallySecurePassword501".to_string()),
master_username: Some("masteruser".to_string()),
db_name: Some("rusotodb".to_string()),
engine: "postgres".to_string(),
multi_az: Some(false...
News & Blog Posts
2017-05-23
~9 min read
rust-analyzer.github.io
...10264 don’t seek outside of character boundaries in completion handler.
#10260 fix name generation in "Generate function" assist.
#10267 narrow if-let to match assist range.
#10282 don’t allow two turbo-fishes in generic arguments.
#10289 only strip derive attributes when preparing macro input.
#10293 don’t bail...
Project/Tooling Updates
2021-09-22
~1 min read
fasterthanli.me
...2
Match arms are patterns
match arms are also patterns, just like if let:
fn print_number(n: Number) {
match n {
Number { odd: true, value } => println!("Odd number: {}", value),
Number { odd: false, value } => println!("Even number: {}", value),
}
}
// this prints the same as before
Exhaustive matches
A match has to be...
News & Blog Posts
2020-03-03
~31 min read
traxys.me
...We need to be careful when categorizing arguments, as we don't want --foo to match a short argument, nor do we want -- to match a long argument.
The reason for introducing a ShortArgument structure is that short arguments are inherently ambiguous.
-abc could be parsed as either -a -b...
Project/Tooling Updates
2024-10-02
~15 min read
wiki.cont.run
...Below is its comment.Desugar `<expr>.await` into:
```rust
match ::std::future::IntoFuture::into_future(<expr>) {
mut pinned => loop {
match unsafe { ::std::future::Future::poll(
<::std::pin::Pin>::new_unchecked(&mut pinned),
::std::future::get_context(task_context),
) } {
::std::task::Poll::Ready(result) => break result,
::std::task::Poll::Pending => {}
}
task...
Rust Walkthroughs
2022-01-26
~14 min read