Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
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
...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
github.com
...If you publish a crate with a `cfg(windows)` dependency then crates.io could expand this to all known triples which match `cfg(windows)` when storing the metadata internally. This would mean that crates using `cfg` syntax would continue to be compatible with older versions of Cargo so long as...
RFC 1361 RFC 2015-11-10 ~4 min read
oxc.rs
...These 200 bytes have to be passed around, and also accessed every time we do a matches!(expr, Expression::Variant(_)) check, which is not very cache friendly for performance.So to make memory access efficient, it is best to box the enum variants.The perf-book describes additional info on...
Project/Tooling Updates 2024-10-09 ~18 min read
guillaume-be.github.io
...A difference is made between the DAG nodes that do exist in the SentencePiece model (marked as leaves) and the nodes that do not have a matching. Every token is pushed by being added to the children of the token containing all characters except the last one: Get the characters...
News & Blog Posts 2020-06-10 ~19 min read
doc.rust-lang.org
pub fn take_error(&self) -> io::Result<Option<io::Error>>
...Examples use std::net::UdpSocket; let socket = UdpSocket::bind("127.0.0.1:34254").expect("bind should succeed"); match socket.take_error() { Ok(Some(error)) => println!("UdpSocket error: {error:?}"), Ok(None) => println!("No error"), Err(error) => println!("UdpSocket.take_error failed: {error:?}"), }
method std Stable since 1.9.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
github.com
...possible extensions ### `match_cfg` The original version of this RFC was more expansive, and proposed a `match_cfg` macro that provided some additional checking. The `match_cfg` macro takes a sequence of `cfg` patterns, followed by `=>` and an expression. Its syntax and semantics resembles that of `match`. However, there are...
RFC 1868 RFC 2016-11-15 ~20 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
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
docs.rs
y4m
...extern crate y4m; use std::io; let mut infh = io::stdin(); let mut outfh = io::stdout(); let mut dec = y4m::decode(&mut infh).unwrap(); let mut enc = y4m::encode(dec.get_width(), dec.get_height(), dec.get_framerate()) .with_colorspace(dec.get_colorspace()) .write_header(&mut outfh) .unwrap(); loop { match...
Crate v0.8.0 2023-04-21
doc.rust-lang.org
pub fn starts_with<P>(&self, base: P) -> bool
...Only considers whole path components to match. Examples use std::path::Path; let path = Path::new("/etc/passwd"); assert!(path.starts_with("/etc")); assert!(path.starts_with("/etc/")); assert!(path.starts_with("/etc/passwd")); assert!(path.starts_with("/etc/passwd/")); // extra slash is okay assert!(path.starts_with("/etc/passwd...
method std Stable since 1.0.0 Version 1.100.0-nightly
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
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
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
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
crates.io
...use docker_credential; use docker_credential::DockerCredential; let credential = docker_credential::get_credential("https://index.docker.io/v1/").expect("Unable to retrieve credential"); match credential { DockerCredential::IdentityToken(token) => println!("Identity token: {}", token), DockerCredential::UsernamePassword(user_name, password) => println!("Username: {}, Password: {}", user_name, password), };
Crate v1.4.0 2026-05-19
doc.rust-lang.org
pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
...The key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type. Examples use std::collections::BTreeMap; let mut map = BTreeMap::new(); map.insert(1, "a"); assert_eq!(map.remove(&1), Some("a")); assert...
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
...The key may be any borrowed form of the map's key type, but Hash and Eq on the borrowed form must match those for the key type. Examples use std::collections::HashMap; let mut map = HashMap::new(); map.insert(1, "a"); assert_eq!(map.remove(&1), Some("a")); assert...
method std Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn var<K>(key: K) -> Result<String, VarError>
...Examples use std::env; let key = "HOME"; match env::var(key) { Ok(val) => println!("{key}: {val:?}"), Err(e) => println!("couldn't interpret {key}: {e}"), }
function std Stable since 1.0.0 Version 1.100.0-nightly
"Memory safety issues mean you can’t trust what you’re seeing in your source code anymore."

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.