lukesteensen.com
...I've
update the code here to match the released APIs and added a section on the new
tokio-io crate.
Introduction
With that out of the way, what is Tokio? The project's most direct inspiration
was Scala's Finagle. Unlike the Scala and the JVM, however, Rust didn...
News & Blog Posts
2016-12-27
~8 min read
bluejekyll.github.io
...for (l, r) in l.chars().zip(r.chars()) {
match l.to_lowercase().cmp(r.to_lowercase()) {
o @ Ordering::Less | o @ Ordering::Greater => return o,
Ordering::Equal => continue,
}
}
} else {
match l.cmp(r) {
o @ Ordering::Less | o @ Ordering::Greater => return o,
Ordering::Equal => continue,
}
}
}
And the new timings:
running 9...
News & Blog Posts
2018-01-02
~26 min read
sindrejohansen.no
...They have similar support for tagged unions and pattern matching. They both
handle errors using the sum-type Result. It’s easy to see how they are
inspired by a similar set of languages.
The big difference is that Elm compiles to JS and Rust compiles to machine code.
The...
News & Blog Posts
2018-11-20
~5 min read
implfuture.dev
...Request<Body>) -> Self::Future {
match <R as Routable>::recognize(req.uri().path()).is_some() {
// if request path matches Yew route, serve S
true => self.yew_service.call(req),
// else serve F
false => self.fallback_service.call(req),
}
}
}
For the full version, check it out on GitHub.With a Yew-route...
Rust Walkthroughs
2022-10-05
~20 min read
asyncmove.com
...usize) -> Result<[u8; 32], &'static str> {
let mut trimmed_address = [0u8; 64];
let mut i = 0;
while i < 64 && start + i < address.len() {
trimmed_address[i] = address.as_bytes()[start + i];
i += 1;
}
let mut bytes = [0u8; 32];
let mut j = 0;
while j < 32 {
let byte = match (
hex_char...
Rust Walkthroughs
2025-01-15
~7 min read
jabberwocky.ca
...Address, data: &mut [u8]) -> Result<(), Error> {
match addr {
// Read from Data Port
0x00 | 0x02 => {
},
// Read from Control Port
0x04 | 0x06 => {
},
_ => { println!("{}: !!! unhandled read from {:x}", DEV_NAME, addr); },
}
Ok(())
}
fn write(&mut self, addr: Address, data: &[u8]) -> Result<(), Error> {
match addr {
// Write to Data Port
0x00 | 0x02 => {
},
// Write to Control...
Rust Walkthroughs
2022-01-12
~31 min read
thunderseethe.dev
...Because Identifier will match let_keyword it’s longer match will win out over LetKw’s let match.We use regex to recognize our integers and whitespace as well.
An integer is one or more digits, recognized by \d+.
Whitespace is one or more spaces, recognized by \s+.Our last...
Rust Walkthroughs
2025-11-12
~34 min read
github.com
...the type `for<'a> fn(Foo<'a>)` is `Copy` for all user-defined types `Foo`, but there is no way to implement `Clone`, which is a supertrait of `Copy`, for it (an `impl<T> Clone for fn(T)` won't match against the higher-ranked type).
The MIR shims for...
RFC 2133
RFC
2017-08-28
~5 min read
rust-lang-nursery.github.io
...String,
}
fn parse_email(s: &str) -> Result<String, String> {
match s.split_once('@') {
Some((user, domain)) if !user.is_empty() && domain.contains('.') => Ok(s.to_string()),
_ => Err("Invalid email format".to_string()),
}
}
fn parse_config(s: &str) -> Result<PathBuf, String> {
let path = PathBuf::from(s);
if path.is_file() {
Ok...
The Rust Cookbook
Book
2024-01-01
~1 min read
blog.servo.org
...gterzian rewrote the image loading algorithm to match the behaviour mandated by the specification.
waffles added support for various CSS Grid properties in Stylo.
jdm removed a GC safety hazard when using CSS transitions.
eloycoto improved the behaviour of getBoundingClientRect for elements with margins and transforms.
cynicaldevil ensured that all...
News & Blog Posts
2017-06-06
~1 min read
blog.nindalf.com
...no_mangle with extern "C" matches 35.8k files.
no_mangle without extern "C" matches 14.8k files.
About a third of functions with this attribute use the Rust ABI. They could be making a conscious choice here, we don’t know. For example, someone on internals.rust-lang.org...
Observations/Thoughts
2023-03-01
~5 min read
ruudvanasseldonk.com
...Let’s try again:pub enum KelvinError {
ParseFailed,
InvalidVersion
}
pub fn check_next_version(previous_versions: &[u32],
version_string: &str)
-> Result<u32, KelvinError> {
let version = match version_string.parse::<u32>() {
Ok(n) => n,
Err(_) => return Err(KelvinError::ParseFailed)
};
if version < previous_versions.iter().cloned().min() {
Ok(version)
} else {
Err(KelvinError...
From the Blogosphere
2015-06-22
~11 min read
guillaumegomez.github.io
...by text “fn main” in a line comment.
@frewsxcv indicated how ChildStd{in,out,err} FDs are closed.
@thombles improved diagnostics when attempting to match tuple enum variant with struct pattern.
@tirr-c made a friendlier error message for closure argument type mismatch.
@estebank pointed at parameter type on E0301...
News & Blog Posts
2017-10-03
~1 min read
crustc.com
...This implies that there may be an error and we handle that using the unwrap() method or match.For example, let’s see an example code that panic: let my_string = "Zeus".to_string();
let my_int = my_string.parse::<i32>().unwrap();Here, we’re trying to convert a string...
Observations/Thoughts
2024-02-28
~1 min read
workers.wasmlabs.dev
...let count = cache.get("counter"); let count_num = match count { Some(count_str) => count_str.parse::<u32>().unwrap_or(0), None => 0, }; let response = format!( "<!DOCTYPE html><body><h1>Key / Value store in Rust</h1><p>Counter: {}</p><p>This page was generated by a Wasm modules built from Rust...
Rust Walkthroughs
2023-01-18
~6 min read
tessera-ui.github.io
...You don't have to follow rules-of-hooks; you can safely use it inside control flow statements like if, loop, match, etc.However, components like virtual lists may not build all child components every frame. Using remember naively could cause state to drift to the next visible component instance...
Rust Walkthroughs
2025-12-17
~8 min read
depth-first.com
...subgraph isomorphism; matching; and cycle perception. Isomorphism finds embeddings and atom/bond mappings between two molecules. Matching is used for kekulization, or the assignment of alternating single/double bonds in certain classes of molecule. Many important molecules in medicine and commerce contain one or more cycles, so cycle perception is...
News & Blog Posts
2020-02-18
~8 min read
thunderseethe.dev
...Ast<TypedVar>) -> IR {
match ast {
//...
}
}
}
We’re well versed in this pattern by now.
Match on the ast and produce an IR term for each case.
First up is variables:Ast::Var(_, TypedVar(var, ty)) => IR::Var(Var::new(
self.supply.supply_for(var),
self.types.lower_ty(ty),
)),
A...
Rust Walkthroughs
2025-02-05
~7 min read
blog.servo.org
...cache use origins intead of full URLs
jmr0 fixed the event suppression logic for pages that have navigated
zakorgy updated some WebBluetooth APIs to match new specification changes
New Contributors
Arthur Marble
Bryan Gilbert
Julien Enselme
Leonardo Santagada
Taryn Hill
Tiziana Sellitto
Interested in helping build a web browser? Take...
New Crates & Project Updates
2016-09-27
~1 min read
slint-ui.com
...This matches the layout produced by a native Qt application much
better and fixes the gallery demo with native style:
The "Button (checkable)" GroupBox is much wider with this change --
much like a similar UI looks in Qt designer.
Janitor work
Fix Node tests in the CI (#1435)
After commit...
Project/Tooling Updates
2022-08-03
~1 min read