Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
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
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
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
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
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
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
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
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
rust-lang.github.io
...rust-lang/rust#51994 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...
Updates from Rust Core 2018-09-18 ~6 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
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
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
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
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
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
ohadravid.github.io
...since the TypeScript document has tokens matching both terms, we will consider it a match for this query. We can let the user specify that they want a more “exact” match, for example by using "javascript language", meaning that the term language must follow the term javascript.Our index currently...
Observations/Thoughts 2025-04-16 ~17 min read
matklad.github.io
...u32) -> Option<Error> { let res = match code { 0 => Error::InvalidSignature, 1 => Error::AccountNotFound, 2 => Error::InsufficientBalance, _ => return None, }; Some(res) } } Now, given that I expect this type to change frequently, this is asking for trouble! It’s very easy for the match and the enum definition to get out of...
Observations/Thoughts 2022-03-30 ~10 min read
github.com
...expected identifier, found keyword `match` --> src/lib.rs:1:4 | 1 | fn match(needle: &str, haystack: &str) -> bool { | ^^^^^ ``` It can instead be written as `fn r#match(needle: &str, haystack: &str)`, using the `r#match` raw identifier, and the compiler will accept this as a true `match` function. Generally when...
RFC 2151 RFC 2017-09-14 ~5 min read
blog.veeso.dev
...Alice }, _ => panic!("Unknown user"),}; This would result in an error, because the type of user canàt be determined error[E0308]: `match` arms have incompatible types --> src/main.rs:36:20 |34 | let user = match name { | ________________-35 | | "carlo" => User { greet: Carlo }, | | --------------------- this is found to be of type `User<Carlo>`36...
Observations/Thoughts 2024-10-30 ~5 min read
"Freedom to shoot yourself in the foot is not a rust marketing point 😉"

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.
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.