Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
ochagavia.nl
...the code used is_some() followed by unwrap(), instead of pattern matching, to extract the option’s inner value. Maybe the code was written before pattern matching was even introduced to the language, and I was the first one to notice it could be improved (language changes were routine in...
Observations/Thoughts 2024-03-13 ~2 min read
rust-analyzer.github.io
#9180 fix some IDE functionality inside attribute macros. #9239 fix coercion in match with expected type. #9182 don’t complete derive macros as function-like macros. #9187 fix edge case in import granularity guessing. #9186 prefer attr macros in "Expand macro recursively". #9191 don’t descend into MacroCall TokenTree delimiters...
Project/Tooling Updates 2021-06-16 ~1 min read
doc.rust-lang.org
pub fn get<Q>(&self, value: &Q) -> Option<&T>
...The value may be any borrowed form of the set's element type, but the ordering on the borrowed form must match the ordering on the element type. Examples use std::collections::BTreeSet; let set = BTreeSet::from([1, 2, 3]); assert_eq!(set.get(&2), Some(&2)); assert_eq!(set...
method alloc Stable since 1.9.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn take<Q>(&mut self, value: &Q) -> Option<T>
...The value may be any borrowed form of the set's element type, but the ordering on the borrowed form must match the ordering on the element type. Examples use std::collections::BTreeSet; let mut set = BTreeSet::from([1, 2, 3]); assert_eq!(set.take(&2), Some(2)); assert_eq...
method alloc Stable since 1.9.0 Version 1.100.0-nightly
doc.rust-lang.org
pub trait Neg
...use std::ops::Neg; #[derive(Debug, PartialEq)] enum Sign { Negative, Zero, Positive, } impl Neg for Sign { type Output = Self; fn neg(self) -> Self::Output { match self { Sign::Negative => Sign::Positive, Sign::Zero => Sign::Zero, Sign::Positive => Sign::Negative, } } } // A negative positive is a negative. assert_eq!(-Sign::Positive, Sign::Negative...
trait core Stable since 1.0.0 Version 1.100.0-nightly
steveklabnik.com
...Record = result?; let replacement = args.replacement.clone(); match &*args.column_name { "name" => record.name = replacement, "surname" => record.surname = replacement, "city" => record.city = replacement, "country" => record.country = replacement, _ => panic!("incorrect column name"), } wtr.serialize(record)?; } wtr.flush()?; Ok(()) } fn main() { let opt = Opt::from_args(); if let Err(err) = run(&opt...
News & Blog Posts 2018-02-20 ~4 min read
amitdev.github.io
...Int) -> bool { match op { Add => x <= y, Sub => x > y, Mul => x != 1 && y != 1 && x <= y, Div => y > 1 && ((x % y) == 0), } } fn apply(op: &Op, x: Int, y: Int) -> Int { match op { Add => x + y, Sub => x - y, Mul => x * y, Div => x / y, } } Apart from syntax, no...
Learn More Rust 2020-08-04 ~7 min read
docs.rs
...assert_eq!(a != b, true); assert_eq!(a.compare(&b), Cmp::Lt); assert_eq!(a.compare_to(&b, Cmp::Lt), true); // Or match the comparison operators match a.compare(b) { Cmp::Lt => println!("Version a is less than b"), Cmp::Eq => println!("Version a is equal to b"), Cmp::Gt...
Crate v0.2.1 2025-10-31
www.christopherbiscardi.com Archived: primary link replaced with an archive on 2026-09-12T17:07:01.695Z (UTC; replacement date, not snapshot date)
...because if has a return value, the type of the return value from both branches has to match. By not writing an else branch, we've declared the return value from the non-existent else branch to be (), which doesn't match with the return type of the if branch...
Learn Standard Rust 2020-08-26 ~2 min read
jsdw.me
...fn poll(&mut self) -> Result<Async<u8>, io::Error> { let mut buf = [0;1]; match self.0.poll_read(&mut buf) { Ok(Async::Ready(_num_bytes_read)) => Ok(Async::Ready(buf[0])), Ok(Async::NotReady) => Ok(Async::NotReady), Err(e) => Err(e) } } } // Now we can use the above to create...
News & Blog Posts 2018-11-27 ~9 min read
system.joekain.com
...modified src/breakpoint/mod.rs @@ -31,13 +31,13 @@ fn set(inferior: &TrapInferior, bp: &Breakpoint) { poke_text(inferior.pid, bp.aligned_address, modified); } -fn find_breakpoint_matching_inferior_instruction_pointer(inf: &Inferior) -> Option<&Breakpoint> { +fn find_breakpoint_matching_inferior_instruction_pointer(inf: &TrapInferior) -> Option<&Breakpoint> { let InferiorPointer(ip) = get_instruction...
Observations/Thoughts 2025-09-03 ~38 min read
doc.rust-lang.org
...Examples: # let (a, b, c) = (0, 1, 2); // For if branches let bar = if true { a } else if false { b } else { c }; // For match arms let baw = match 42 { 0 => a, 1 => b, _ => c, }; // For array elements let bax = [a, b, c]; // For closure with multiple return statements let clo...
The Rust Reference Book 2024-01-01 ~7 min read
doc.rust-lang.org
pub fn get<Q>(&self, value: &Q) -> Option<&T>
...The value may be any borrowed form of the set's value type, but Hash and Eq on the borrowed form must match those for the value type. Examples use std::collections::HashSet; let set = HashSet::from([1, 2, 3]); assert_eq!(set.get(&2), Some(&2)); assert_eq!(set...
method std Stable since 1.9.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn take<Q>(&mut self, value: &Q) -> Option<T>
...The value may be any borrowed form of the set's value type, but Hash and Eq on the borrowed form must match those for the value type. Examples use std::collections::HashSet; let mut set = HashSet::from([1, 2, 3]); assert_eq!(set.take(&2), Some(2)); assert_eq...
method std Stable since 1.9.0 Version 1.100.0-nightly
 What's New in Rust 1.42 and 1.43
1:10:53
Rustacean Station rustacean-station.org
...Like, I want to match match on this pattern, but also bind the entire thing, not just the inside, but the entire thing to some name. Well, specifically, like, bind bind it to this name if it matches. Mhmm. So for example, if I have, like, an array of, like...
Podcast 2020-05-08 1:10:53
crates.io
...TcpStream, ) -> Result<(), WebSocketError> { handshake(&mut socket).await?; let mut ws = WebSocket::after_handshake(socket); ws.set_writev(true); ws.set_auto_close(true); ws.set_auto_pong(true); loop { let frame = ws.read_frame().await?; match frame { OpCode::Close => break, OpCode::Text | OpCode::Binary => { let frame = Frame::new(true, frame...
Crate v0.8.1 2026-01-01
kerkour.com
...String, } #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let cli_matches = App::new("Rust to the mooooon") .version("1.0") .arg( Arg::with_name("concurrency") .short("c") .long("concurrency") .help("Number of concurrent inserts") .default_value("3"), ) .arg( Arg::with_name("inserts") .short("i") .long("inserts...
Observations/Thoughts 2021-08-04 ~5 min read
ceronman.com
...This would require changing the data layout of the structs to match C. The problem with using an enum is that a match operation is required on every dereference. I believe this match should be optimized out by the compiler, but I haven’t properly checked. But even then, struct...
Observations/Thoughts 2021-07-28 ~25 min read
doc.rust-lang.org
...In the following example, surrounding the matcher with $(...),+ will match one or more expression, separated by commas. Also note that the semicolon is optional on the last case. // `find_min!` will calculate the minimum of any number of arguments. macro_rules! find_min { // Base case: ($x:expr) => ($x); // `$x` followed...
Rust by Example Book 2024-01-01 ~1 min read
rust-analyzer.github.io
...UnevaluatedConst before trait solving. #14890 use ::core instead of $crate in option_env! expansion. #14893 fix need-mut false positive in closure capture of match scrutinee. #14874 change how #![cfg(FALSE)] behaves on crate root. #14895 don’t try to determine type of token inside macro calls. #14904 render size...
Project/Tooling Updates 2023-05-31 ~1 min read
"BurntSushi is a super experienced programmer who always seems to know what’s right Shepmaster occasionally pops up to keep things level, and provid..."

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.