Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
asquera.de
...let res = match req { ExampleRequest::Get { url: url } => { match db.get(&url) { Some(v) => ExampleResponse::Ok { content: v.clone() }, None => ExampleResponse::NotFound, } }, ExampleRequest::Post { url: url, content: content } => { match db.insert(url, content) { Some(v) => ExampleResponse::Ok { content: v }, None => ExampleResponse::Ok { content: "".into() }, } } }; println!("Database: {:?}", *db); // Return the result...
News & Blog Posts 2017-03-07 ~26 min read
rust-lang.github.io
...We will also query the oauth_github table to see if the crates.io username and GitHub username match. If they do match, we will continue with adding this user as an owner. If they don't match, we will return an error containing information about the mismatch and asking...
RFC 3946 RFC 2026-04-07 ~28 min read
rustc-dev-guide.rust-lang.org
...Most error annotations need to match with the line of the diagnostic. There are several ways to match the message with the line (see the examples below): • ~: Associates the error level and message with the current line • ~^: Associates the error level and message with the previous error annotation line. Each...
Guide to Rustc Development Book 2024-01-01 ~19 min read
rust-lang.github.io
...Unresolved questions • The behavior specified here should match the behavior of MSVC at least. Does it match the behavior of other C/C++ compilers as well? • Should it still be safe to borrow fields whose alignment is less than or equal to the specified packing or should all field borrows...
RFC 1399 RFC 2015-12-06 ~3 min read
lwn.net
...Another improvement to the language's usability is a proposed infix pattern-matching operator. Rust has some support for pattern matching inside conditionals, but that can result in having to read the condition in an awkward order, Triplett explained. For example, this code matches the pattern Some(x) against the...
Observations/Thoughts 2026-10-28 ~12 min read
matthewkmayer.github.io
...pub fn generate_source(service: &Service, writer: &mut FileWriter) -> IoResult { match service.protocol() { "json" => generate(writer, service, JsonGenerator, JsonErrorTypes), "query" | "ec2" => generate(writer, service, QueryGenerator, XmlErrorTypes), "rest-json" => generate(writer, service, RestJsonGenerator, JsonErrorTypes), "rest-xml" => generate(writer, service, RestXmlGenerator, XmlErrorTypes), protocol => panic!("Unknown protocol {}", protocol), } } The function signature shows it...
News & Blog Posts 2017-06-27 ~8 min read
developerlife.com
...This combinator takes a range of characters (2, 2) and applies the function match_is_hex_digit to determine whether the char is a hex digit (using is_ascii_hexdigit() on the char). This is used to match a valid hex digit. It returns a &str slice of the matched...
Rust Walkthroughs 2023-05-24 ~20 min read
calculist.org
...function search(corpus, search) { var ls = lines(corpus); var total = 0; for (var i = 0, n = ls.length; i < n; i++) { total += wcLine(ls[i], search); } return total; } Searching an individual line involves splitting the line up into word and matching each word against the search string: function wcLine(line...
News & Blog Posts 2015-12-28 ~6 min read
iev.ee
nginx/1.28.0
Observations/Thoughts 2026-03-18 ~1 min read
hacks.mozilla.org
...This function is essentially just a large match statement over the opcode of the root CLIF instruction, with the match-arms looking deeper as needed. Here is a simplified version of the match-arm for an integer add operation lowered to AArch64 (the full version is here): <span class="k...
Observations/Thoughts 2020-10-14 ~17 min read
rust-lang.github.io
...F) -> U { match self { Some(t) => f(t), None => Default::default(), } } } The following implementation would get added to core::result::Result: impl<T, E> Result<T, E> { pub fn map_or_default<U: Default, F: FnOnce(T) -> U>(self, f: F) -> U { match self { Ok(t) => f(t), Err(e...
RFC 3148 RFC 2021-07-14 ~1 min read
www.seventeencups.net
...i32) -> f32 { match index { 0 => self.threshold, _ => 0.0, } } fn set_parameter(&mut self, index: i32, value: f32) { match index { // We don't want to divide by zero, so we'll clamp the value 0 => self.threshold = value.max(0.01), _ => (), } } fn get_parameter_name(&self, index: i32) -> String { match...
News & Blog Posts 2017-03-28 ~6 min read
siciarz.net
...use std::env; fn main() { match env::var("LANG") { Ok(lang) => println!("Language code: {}", lang), Err(e) => println!("Couldn't read LANG ({})", e), }; } $ cargo run Language code: pl_PL.UTF-8 envy envy is a small crate that uses serde to automatically deserialize process environment into a Rust struct. #![feature...
News & Blog Posts 2016-12-06 ~3 min read
www.fpcomplete.com
...This function is all about pattern matching and unifying the error representation using .into(): fn poll_ready( &mut self, cx: &mut std::task::Context<'_>, ) -> std::task::Poll<Result<(), Self::Error>> { match self.web.poll_ready(cx) { Poll::Ready(Ok(())) => match self.grpc.poll_ready(cx) { Poll::Ready(Ok(())) => Poll::Ready...
Rust Walkthroughs 2021-09-22 ~11 min read
radekmie.dev
...It’d look like this:// The below code is just a simplification -- it may not compile! impl<Id> Expression<Id> { fn add_casts(&self, type_: &Type<Id>) -> Result<Self, Error<Id>> { let mut clone = match self { Self::Access { lhs, rhs } => { let lhs_type = lhs.infer()?; let Type::Arrow { lhs: key...
Observations/Thoughts 2024-04-03 ~4 min read
rustc-dev-guide.rust-lang.org
...The subroutines that decide whether a particular impl/where-clause/etc applies to a particular obligation are collectively referred to as the process of matching. For impl candidates , this amounts to unifying the impl header (the Self type and the trait arguments) while ignoring nested obligations. If matching succeeds then...
Guide to Rustc Development Book 2024-01-01 ~7 min read
blog.logrocket.com
...fn main() { let args = Arguments::parse(); let logger = logger::DummyLogger::new(args.verbosity as usize); match args.cmd { SubCommand::Count { package_name } => match count(&package_name, args.max_depth, &logger) { Ok(c) => println!("{} uses found", c), Err(e) => eprintln!("error in processing : {}", e), }, SubCommand::Projects { start_path, exclude, } => match projects...
Rust Walkthroughs 2022-04-20 ~23 min read
doc.rust-lang.org
...match operand.into_future() { mut pinned => loop { let mut pin = unsafe { Pin::new_unchecked(&mut pinned) }; match Pin::future::poll(Pin::borrow(&mut pin), &mut current_context) { Poll::Ready(r) => break r, Poll::Pending => yield Poll::Pending, } } } where the yield pseudo-code returns Poll::Pending and, when re-invoked, resumes...
The Rust Reference Book 2024-01-01 ~1 min read
thedataquarry.com
...The key difference here is how we use a match statement to replace multiple patterns using a single closure. The &capture[2] syntax is used to access the second capture group in the regex match, which is the suffix of the contraction, and this is then passed to the match...
Rust Walkthroughs 2024-02-14 ~19 min read
tech.nextroll.com
...For your sanity, the match statement in this function is shortened for this example. fn recurse(stmt: &Statement, errors: &mut Vec<String>, mut is_global: bool) { let mut allow_vars = true; if is_global { is_global = false; allow_vars = false; } match stmt { Statement::FunctionDeclaration(func) => match func { FunctionDeclarationStat::Local { body...
Rust Walkthroughs 2022-07-13 ~4 min read
"A rustacean is a programmer that dislikes being told "yes" in situations where they'll regret it later."

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.