Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
rust-analyzer.github.io
...left braces. #16822 improve resolution for inlay hints targeting the same position. #16871, #16886 skip problematic cyclic dev-dependencies. #16885 improve parser recovery for match arms. #16812 fix "Go to implementation" for impls inside blocks. #16909 keep the Attr::Literal spans. #16911 fix hang on projects depending on rustc_private.
Project/Tooling Updates 2024-03-27 ~1 min read
doc.rust-lang.org
pub struct SystemTimeError
...Examples use std::thread::sleep; use std::time::{Duration, SystemTime}; let sys_time = SystemTime::now(); sleep(Duration::from_secs(1)); let new_sys_time = SystemTime::now(); match sys_time.duration_since(new_sys_time) { Ok(_) => {} Err(e) => println!("SystemTimeError difference: {:?}", e.duration()), }
struct std Stable since 1.8.0 Version 1.100.0-nightly
RustFest www.youtube.com
...Functional languages have potential and are safe since they are ADT and pattern matching. But they’re not good for quick interpreters due to its runtime. Conversely, C is quick and has no runtime, but it’s not safe. I was searching for an ADT and pattern matching language that...
Talk κeen 2020-11-07
kerkour.com
...fn do_something() -> Result<(), Error> { let user = get_user_opt().ok_or(Error::UserNotFound)?; // do something } match Then, of course, there is match: fn do_something() -> Result<(), Error> { let user = match get_user_opt() { Some(user) => user, None => return Err(Error::UserNotFound); }; // do something } if let / let else Even better...
Observations/Thoughts 2025-11-26 ~6 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
docs.rs
...When searching for more than one byte, positions are considered a match if the byte at that position matches any of the bytes. The memmem sub-module provides forward and reverse substring search routines. In all such cases, routines operate on &[u8] without regard to encoding. This is exactly what...
Crate v2.8.3 2026-07-08
sergey-melnychuk.github.io
...process socket events for event in &events { match event.token() { Token(0) => { loop { match listener.accept() { Ok((socket, _)) => { // accept connection, create Handler }, Err(_) => break } } }, token if event.readiness().is_readable() => { debug!("token {} readable", token.0); if let Some(handler) = handlers.remove(&token) { event_tx.send(handler).unwrap(); } }, token if event...
News & Blog Posts 2020-05-05 ~4 min read
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
trieve.ai
...Our algorithm prioritizes prefix matches and factors in the frequency of each candidate word within the dataset. fn is_best_correction(word: &str, correction: &str) -> bool { // Length-based filter let len_diff = (word.len() as i32 - correction.len() as i32).abs(); if len_diff > 2 { return false; } // Prefix matching (adjust...
Observations/Thoughts 2024-09-11 ~6 min read
crates.io
...pub enum DbDriver { Postgresql, Mysql, } impl std::str::FromStr for DbDriver { type Err = String; fn from_str(s: &str) -> Result<Self, Self::Err> { match s.trim().to_lowercase().as_ref() { "postgres" => Ok(DbDriver::Postgresql), "mysql" => Ok(DbDriver::Mysql), _ => Err(format!("Unknown DB driver: {s}")) } } } #[derive(Envconfig)] pub struct DbConfig { // ... #[envconfig...
Crate v0.11.1 2025-12-10
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
crates.io
...pub enum DbDriver { Postgresql, Mysql, } impl std::str::FromStr for DbDriver { type Err = String; fn from_str(s: &str) -> Result<Self, Self::Err> { match s.trim().to_lowercase().as_ref() { "postgres" => Ok(DbDriver::Postgresql), "mysql" => Ok(DbDriver::Mysql), _ => Err(format!("Unknown DB driver: {s}")) } } } #[derive(Envconfig)] pub struct DbConfig { // ... #[envconfig...
Crate v0.11.1 2025-12-10
kerkour.com
...Vec<String>, output_dir: &str) -> Result<(), anyhow::Error> { let mut html = templates::HEADER.to_owned(); let body = files .into_iter() .map(|file| { let file = file.trim_start_matches(output_dir); let title = file.trim_start_matches("/").trim_end_matches(".html"); format!(r#"<a href="{}">{}</a>"#, file, title) }) .collect::<Vec<String...
Rust Walkthroughs 2021-09-29 ~3 min read
adventures.michaelfbryan.com
...Value) -> Result<bool, Self::Error> { match other { Value::Bool(b) => Ok(b), _ => Err(Error::BadVariableType), } } } impl TryFrom<Value> for i32 { type Error = Error; fn try_from(other: Value) -> Result<i32, Self::Error> { match other { Value::Integer(i) => Ok(i), _ => Err(Error::BadVariableType), } } } impl TryFrom<Value> for f64 { type Error = Error...
News & Blog Posts 2019-12-17 ~37 min read
doc.rust-lang.org
pub const fn unwrap(self) -> T
...Instead, prefer to use pattern matching and handle the None case explicitly, or call unwrap_or, unwrap_or_else, or unwrap_or_default. In functions returning Option, you can use the ? (try) operator. Panics Panics if the self value equals None. Examples let x = Some("air"); assert_eq!(x.unwrap...
method core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub const fn map<U, F>(self, op: F) -> Result<U, E>
...let line = "1\n2\n3\n4\n"; for num in line.lines() { match num.parse::<i32>().map(|i| i * 2) { Ok(n) => println!("{n}"), Err(..) => {} } }
method core Stable since 1.0.0 Version 1.100.0-nightly
""Rust compilation is so slow that I can fix the bugs while it still compiles the crates""

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.