Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
hackeryarn.com
...Matching multi-field select #[macro_export] macro_rules! query { ( from $db:ident select $( $field:ident ),+ ) => { ... }; } That's quite a bit of new syntax, but it all breaks down to a single new matching construct. Repetition match syntax The general shape for matching repetition looks like: $ ( ... ) sep rep => { ... $ ( ... ) rep ... } We need...
Rust Walkthroughs 2025-09-03 ~6 min read
www.ferrisfencing.org
...The Rules Matches are contested between two fencers, each named Ferris, and each running in their own VM. The fencers square off on a one-dimensional grid 10 spaces wide. Each match consists of 5 games. The player to win the most games wins the match. Games consist of up...
News & Blog Posts 2019-10-29 ~1 min read
coaxion.net
...State::HaveHeader {ref header, ref mut have_header_state } => { match *have_header_state { HaveHeaderState::Skipping { to_skip: 0 } => { *have_header = HaveHeaderState::Streaming { audio: ...}; } }, } match self.state { ... State::HaveHeader {ref header, ref mut have_header_state } => { match *have_header_state { HaveHeaderState::Skipping { to_skip: 0 } => { *have_header = HaveHeaderState::Streaming { audio: ...}; } }, } match...
News & Blog Posts 2016-11-29 ~8 min read
lifthrasiir.github.io
...MyTrait; // @matches foo/trait.Bravo.html '//pre' "Bravo.*where.*B:.*MyTrait" pub trait Bravo<B> where B: MyTrait {} // @matches foo/fn.charlie.html '//pre' "charlie.*where.*C:.*MyTrait" pub fn charlie<C>() where C: MyTrait {} pub struct Delta<D>; // @matches foo/struct.Delta.html '//*[@class="impl"]//code' "impl.*Delta.*where...
Blog Posts 2015-01-19 ~2 min read
blog.servo.org
...Selector matching has been extracted into an independent library! You can see it here. We now have automation set up for our Gonk (Firefox OS) port, and gate on it. Notable additions Chris Paris landed fragment parsing in html5ever and implemented the innerHTML setter in Servo. Jack Moffitt added a...
Project Updates 2015-03-02 ~1 min read
sled.rs
...fn may_fail() -> Result<Happy, Sad> { /* either returns Ok(Happy) or Err(Sad) */ } fn caller() { match may_fail() { Ok(happy) => println!(":)"), Err(sad) => { eprintln!(":("); /* handle error */ return; } } match may_fail() { Ok(happy) => println!(":)"), Err(sad) => { eprintln!(":("); /* handle error */ return; } } match may_fail() { Ok(happy) => println!(":)"), Err(sad) => { eprintln!(":("); /* handle error...
News & Blog Posts 2020-04-07 ~16 min read
pwy.io
...Date| -> Span { // Check if `curr` matches any of the `BYDAY` rules // (evaluates to `true` if `by_day` is empty) let matches_by_day = recur.by_day.iter().any(|wd| { curr.weekday() == wd }); // Check if `curr` matches any of the `BYMONTHDAY` rules // (evaluates to `true` when `by_month_day` is empty...
Observations/Thoughts 2025-04-23 ~23 min read
rust-lang.github.io
Summary Tuple structs can now be constructed and pattern matched with Self(v1, v2, ..). A simple example: struct TheAnswer(usize); impl Default for TheAnswer { fn default() -> Self { Self(42) } } Similarly, unit structs can also be constructed and pattern matched with Self. Motivation This RFC proposes a consistency fix allowing Self...
RFC 2302 RFC 2017-01-18 ~6 min read
siciarz.net
...MATCH Option,166,9,/home/zbyszek/Development/Rust/rust/src/libcore/option.rs,Enum,pub enum Option<T> { MATCH Item,774,11,/home/zbyszek/Development/Rust/rust/src/libcore/option.rs,Struct,pub struct Item<A> { MATCH None,168,4,/home/zbyszek/Development/Rust/rust/src/libcore/option.rs,EnumVariant...
24 Days of Rust continues! 2014-12-15 ~2 min read
cbreeden.github.io
...usize) -> Test { match n { 0 => Test::A, 1 => Test::B, _ => unreachable!(), } } We will need to fill in those branches with #(#match_usize)*. After that, the iterator is quite easy to implement. Match the current count with an enum variant, increment the count, and return that enum. That seems straightforward. So...
News & Blog Posts 2017-01-03 ~11 min read
unconj.ca
...These two processes can be represented using a simple function that makes use of Rust’s match construct: fn algae_rule(input: Algae) -> Vec<Algae> { match input { Algae::A => vec!(Algae::A, Algae::B), Algae::B => vec!(Algae::A) } } If we take the Algae type as representing the L-system...
Notable Links 2015-06-07 ~7 min read
doc.rust-lang.org
...use std::collections::HashMap; fn call(number: &str) -> &str { match number { "798-1364" => "We're sorry, the call cannot be completed as dialed. Please hang up and try again.", "645-7689" => "Hello, this is Mr. Awesome's Pizza. My name is Fred. What can I get for you today?", _ => "Hi...
Rust by Example Book 2024-01-01 ~1 min read
bodil.lol
...fn identifier(input: &str) -> Result<(&str, String), &str> { let mut matched = String::new(); let mut chars = input.chars(); match chars.next() { Some(next) if next.is_alphabetic() => matched.push(next), _ => return Err(input), } while let Some(next) = chars.next() { if next.is_alphanumeric() || next == '-' { matched.push(next); } else { break; } } let...
News & Blog Posts 2019-04-23 ~54 min read
hassamuddin.com
...Packet ) { match packet { Packet::Pingreq => { println!("Ping"); framed.send(Packet::Pingresp).await; } _ => { // now what? } } } pub async fn handle_client( stream: TcpStream, addr: SocketAddr ) { let mut framed = Framed::new(stream, MQTTCodec::new()); // do connection handshake let connect = match framed.next().await { Some(Ok(Packet::Connect(packet))) => { framed.send(Packet::Connack( Connack...
Learn More Rust 2020-09-04 ~7 min read
blog.cloudflare.com
...It’s built using our engine, Wirefilter, which takes powerful boolean expressions written by customers and matches incoming requests against them. Customers can then choose how to respond to traffic which matches these rules. We will discuss some in-depth optimizations we have recently made to Wirefilter, so you may...
Miscellaneous 2020-09-30 ~11 min read
doc.rust-lang.org
...Within $() is $x:expr, which matches any Rust expression and gives the expression the name $x. The comma following $() indicates that a literal comma separator character must appear between each instance of the code that matches the code in $(). The * specifies that the pattern matches zero or more of whatever...
The Rust Programming Language Book 2024-02-01 ~17 min read
tech.marksblogg.com
...fn main() { let matches = command!() .arg(arg!(--function <VALUE>).required(true)) .get_matches(); let function = matches.get_one::<String>("function").expect("required"); loop { let mut input = String::new(); match io::stdin().read_line(&mut input) { Ok(n) => { if n == 0 { // End files break; } let mut result = match function.as_str...
Rust Walkthroughs 2023-09-20 ~4 min read
rust-analyzer.github.io
...layer. #10689 handle pub tuple fields in tuple structs. #10720 don’t ascribe types in pattern completion for param patterns twice. #10747 remove faulty logic for ascending test attributes for runnables. #10762 trigger flyimport on enum variants. #10759 make add_missing_match_arms applicable at the end of the match.
Project/Tooling Updates 2021-11-17 ~1 min read
tweedegolf.nl
...messageBytes, message_type } = received; assert.strictEqual(sender, alice_identifier, "Sender does not match Alice's identifier"); let receivedMessage = String.fromCharCode.apply(null, messageBytes); assert.strictEqual(receivedMessage, message, "Received message does not match"); assert.strictEqual(message_type, MessageType.SignedAndEncrypted, "Message type does not match SignedAndEncrypted"); } else { assert.fail(`Unexpected message type...
Rust Walkthroughs 2024-10-02 ~7 min read
github.com
## Summary [summary]: #summary Tuple `struct`s can now be constructed and pattern matched with `Self(v1, v2, ..)`. A simple example: ```rust struct TheAnswer(usize); impl Default for TheAnswer { fn default() -> Self { Self(42) } } ``` Similarly, unit structs can also be constructed and pattern matched with `Self`. ## Motivation [motivation]: #motivation This RFC...
RFC 2302 RFC 2017-01-18 ~7 min read
"Rust doesn't give you good errors, it gives you control over errors."

Search tips

Type anything to search across articles, videos (including conference talks), podcasts, research, crates, and Rust API documentation. These operators give you finer control — click an example to try it.

Find pages containing all your words. Pages where the words appear together rank higher.
Quote part of your query to keep those words together as an exact phrase within a larger search.
Wrap the whole query in quotes for a verbatim search that matches text exactly, punctuation and all — perfect for Rust syntax. Needs at least 3 characters.
Put ! first to open the top result immediately. Quote the whole query for a literal leading bang, as in '!Send'. Bangs elsewhere, such as println!, stay literal. Browser and launcher shortcuts can invoke this directly. See search integrations.
Limit results to a single site. Works on its own () too. One site: per search.

Use the tabs and filters above the results to narrow by content type, publication year, and sort order.