Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
priver.dev
...Serialize>(t: &T) { let serialized = serde_json::to_string(t).unwrap(); println!("{}", serialized); } pub async fn new(db_url: &str) -> Result<Box<dyn DatabaseDriver>> { if db_url.starts_with("libsql") { let token = match config::database_token() { Ok(t) => t, Err(err) => bail!("{}", err), }; let client = match libsql::LibSQLDriver::new(db...
Rust Walkthroughs 2023-12-20 ~8 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
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
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
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
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
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
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
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
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
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
"Compilers are an error reporting tool with a code generation side-gig."

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.