Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
ibraheem.ca
...Like a match statement, but for I/O operations. loop { // If only... match { ctrl_c() => { break; }, Ok((connection, _)) = listener.accept() => { std::thread::spawn(|| ...); } } } And what about timing out long running requests after thirty seconds? We could set a flag that tells threads to stop, but how often would they check...
Observations/Thoughts 2023-08-16 ~88 min read
rust-lang.github.io
...let a: [uint; 2] = [0u; 2]; Match patterns In match patterns, .. is always interpreted as a wildcard for constructor arguments (or for slice patterns under the advanced_slice_patterns feature gate). This RFC does not change that. In a match pattern, .. will always be interpreted as a wildcard, and never...
RFC 520 RFC 2014-12-13 ~5 min read
quickwit.io
...a RegexPhraseQuery "b.* b.* wolf" matches "big bad wolf". Slop is supported as well: "bi.* wolf"~2 matches "big bad wolf". #2516This feature comes with some new Postings implementations to handle the complexity of potentially 100000 terms. They may be useful for other use cases:SimpleUnion A union docset for...
Project/Tooling Updates 2025-06-25 ~3 min read
pietro.menna.net.br
...PeerMessage) -> Result<(), Error> { match message { PeerMessage::CancelRequest(piece_index, block_index) => { match self.requests_in_progress.iter().position(|r| r.matches(piece_index, block_index)) { Some(i) => { let r = self.requests_in_progress.remove(i); self.send_message(Message::Cancel(r.piece_index, r.offset, r.block_length)) }, None => Ok...
From the Blogosphere 2015-06-22 ~7 min read
aturon.github.io
...DomString) -> AttrValue { match name { &atom!("id") => AttrValue::from_atomic(value), &atom!("class") => AttrValue::from_serialized_tokenlist(value), _ => default::parse_plain_attribute(self, name, value), } } } impl ParsePlainAttribute for HtmlAnchorElement { fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue { match name { &atom!("rel") => AttrValue::from_serialized_tokenlist(value), _ => default::parse_plain...
News & Blog Posts 2015-09-21 ~24 min read
www.snoyman.com
...f64, } #[derive(Clone, Copy)] enum State { Arizona, Nevada, Utah, } impl State { fn tax_rate(self) -> f64 { match self { State::Arizona => 0.05, State::Nevada => 0.08, State::Utah => 0.09, } } } #[derive(Clone, Copy)] enum Item { Apples, Eggs, } impl Item { fn price(self) -> f64 { match self { Item::Apples => 0.5, Item...
Rust Walkthroughs 2024-08-28 ~10 min read
www.fpcomplete.com
...So let's rewrite this without any early return, and instead use some pattern matching: fn age() -> Option<i32> { match (birth_year(), current_year()) { (Some(birth_year), Some(current_year)) => Some(current_year - birth_year), _ => None, } } This certainly works, but it's verbose. It also doesn't generalize to other...
Observations/Thoughts 2020-12-09 ~22 min read
dystroy.org
...Result<T, E>) -> T { match res { Ok(v) => v, Err(e) => { log::error!("Fatal error: {}", e); Timer::after_millis(100).await; panic!("Fatal error: {}", e); } } } #[embassy_executor::main] async fn main(spawner: Spawner) { let p = embassy_rp::init(Default::default()); // Logger USB — must be before everything else let usb_driver...
Rust Walkthroughs 2026-06-17 ~50 min read
rust-lang.github.io
...However, if you're using Clippy, this will cause the match_same_arms lint to trip! You can silence the lint in this spot, and provide an explanation that indicates you are doing so deliberately, by placing this attribute above the match line: #[allow(match_same_arms, reason = "The arms...
RFC 2383 RFC 2018-04-02 ~9 min read
matthewkmayer.github.io
...fn make_org_url(matches: &clap::ArgMatches) -> String { let org = matches .value_of("ORG") .expect("Please specify a github org"); if !org_is_just_org(&org) { match suggest_org_arg(&org) { Ok(suggestion) => panic!("Try this for the org value: {}", suggestion), Err(_) => panic!("Please make org just the organization name...
News & Blog Posts 2017-10-24 ~6 min read
www.worthe-it.co.za
...It follows that the lifetime of variables used inside the new thread must match those of the new thread, not the function that it was spawned from.use std::thread; let outside_value = String::from("Hello world"); let child_thread = thread::spawn(move || { // this new thread may outlive the context...
News & Blog Posts 2017-07-18 ~10 min read
blog.scottlogic.com
...It first casts times to a signed integer so that it can support negative values and uses a match to work out a transformation to apply based on the current direction. The match control-flow operator is an extremely powerful feature of Rust, similar to Scala’s match or a...
Learn Simple Rust 2020-10-14 ~36 min read
jtjlehi.github.io Archived: primary link replaced with an archive on 2026-09-12T14:44:56.786Z (UTC; replacement date, not snapshot date)
...let (removes, inserts): (Vec<_>, Vec<_>) = updates .into_iter() // we have to make sure that removes happen at the correct offset .scan(0, |num_inserts, update| { Some(match update { Update::Remove(idx) => Update::Remove(idx + *num_inserts), insert @ Update::Insert(_, _) => { *num_inserts += 1; insert } }) }) .partition(|updates| matches!(updates, Update::Remove(_))) To...
Rust Walkthroughs 2025-03-26 ~14 min read
rust-analyzer.github.io
#10608 (first contribution) amend the rustup installation instructions. #10574, #10578 fix "Generate PartialOrd implementation" codegen. #10568 improve codegen for "Unwrap Result return type". #10585 resolve derive attributes even when shadowed. #10587 fix add_missing_match_arm panicking on failed upmapping. #10589 expand unused glob import into {}. #10594 generate and complete...
Project/Tooling Updates 2021-10-27 ~1 min read
blog.sebastiansastre.co
...In our snippet, the Suspend arm does what handle_suspend does; the match is already a branch. A match on an enum compiles to a jump table or a chain of comparisons. You’ve already paid for a branch. Adding a function call inside one arm adds roughly one more...
Observations/Thoughts 2026-03-11 ~7 min read
pwy.io
...calling `.city.to_owned()` here is inefficient, because it // will allocate a new string even if the hashmap already contains // the entry; this can be avoided with `.raw_entry_mut()`, but // let's not go crazy } Self { indexed_prices } } /// Returns indices of prices matching given city and occupancy. fn find...
Observations/Thoughts 2024-10-16 ~5 min read
hugopeixoto.net
...Applying the same thresholding and connected pixels detection to this template, I could find the one that more closely matched the digit being detected using Template Matching. In short, this algorithm goes through each pixel inside the bounding box of both the template and the digit, finds how many pixels...
Rust Walkthroughs 2022-03-16 ~7 min read
rust-analyzer.github.io
...trying to use an uncached syntax node in Semantics. #10460 only add proc_macro to prelude in proc-macro crates. #10477 fix parsing of macro call inside generic args. #10449 fix parsing of Some(1..). #10420 parse outer attributes on StructPatternEtCetera. #10480 change snake case fix to match rustc implementation.
Project/Tooling Updates 2021-10-13 ~1 min read
dev.to
...Option<String> = Option::None; loop { std::thread::sleep(time::Duration::from_secs(1)); println!("Waiting for event..."); let evt = next_event(&client, &r.extension_id); if let Some(req_id) = prev_request.take() { process_result(req_id); } match evt { Ok(evt) => match evt { NextEventResponse::Invoke { request_id, deadline_ms, .. } => { println...
Rust Walkthroughs 2020-11-04 ~10 min read
blog.logrocket.com
...To handle an enum in Rust, you have to match on it. Every time you match on an enum, the compiler makes sure you’re handling all the variants. Not handling a variant is a compile-time error unless you explicitly opt into this behavior using _ => .... #[must_use] Types and...
Learn Standard Rust 2020-08-04 ~11 min read
"In \[other languages\], I could end up chasing silly bugs and waste time debugging and tracing to find that I made a typo or ran into a language quirk..."

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.