Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
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
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
doc.rust-lang.org
pub fn iter_mut(&mut self) -> IterMut<'_, T>
Option::iter_mut — Returns a mutable iterator over the possibly contained value. Examples let mut x = Some(4); match x.iter_mut().next() { Some(v) => *v = 42, None => {}, } assert_eq!(x, Some(42)); let mut x: Option<u32> = None; assert_eq!(x.iter_mut().next(), None);
method core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub struct SocketAddr
SocketAddr — An address associated with a Unix socket. Examples use std::os::unix::net::UnixListener; let socket = match UnixListener::bind("/tmp/sock") { Ok(sock) => sock, Err(e) => { println!("Couldn't bind: {e:?}"); return } }; let addr = socket.local_addr().expect("Couldn't get local address");
struct std Stable since 1.10.0 Version 1.100.0-nightly
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
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...
Updates from Rust Core 2018-10-30 ~9 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
FOSDEM archive.fosdem.org
...Some of these are fundamental novelties, and others are optimizations matching the changing performance landscape in modern hardware. In this talk we present Glidesort, a general purpose in-memory stable comparison sort. It is fully adaptive to both pre-sorted runs in the data similar to Timsort, and low-cardinality...
Talk Orson Peters 2023-02-04
rust-analyzer.github.io
...numeric literals. #13746 keep comments in "Extract function". #13774 resolve all inference variables in InferenceResult::assoc_resolutions. #13777 parse if correctly after a half-open range in match. #13783, #13784 add parentheses to binding mode hints when they attach to an Or-pattern. #13766 fix config patching logic for addCallParenthesis.
Project/Tooling Updates 2022-12-21 ~1 min read
doc.rust-lang.org
pub fn pair() -> io::Result<(UnixStream, UnixStream)>
UnixStream::pair — Creates an unnamed pair of connected sockets. Returns two UnixStreams which are connected to each other. Examples use std::os::unix::net::UnixStream; let (sock1, sock2) = match UnixStream::pair() { Ok((sock1, sock2)) => (sock1, sock2), Err(e) => { println!("Couldn't create a pair of sockets: {e:?}"); return } };
associated_function std Stable since 1.10.0 Version 1.100.0-nightly
docs.rs
...extern crate http_range; use http_range::{HttpRange}; fn main() { let range_str = "bytes=0-8"; let size = 10; match HttpRange::parse(range_str, size) { Ok(rngs) => for r in rngs { println!("Start {}, length {}", r.start, r.length) }, Err(err) => println!("HttpRange parse error: {:?}", err) }; } Used in iron-send-file...
Crate v0.1.5 2022-02-15
doc.rust-lang.org
pub mod ffi
...This module provides types which will match those defined by C, so that code that interacts with C will refer to the correct types.
module core Stable since 1.30.0 Version 1.100.0-nightly
www.youtube.com
...we see two matched statements when statements are kind of like switch statements and other languages but even one powerful each line in the match statement starts with a pattern and if the pattern matches the rest of the line oh and if the pattern matches the rest of the...
Video 2018-03-31
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
doc.rust-lang.org
fn cmp(&self, other: &Self) -> Ordering
...By convention, self.cmp(&other) returns the ordering matching the expression self <operator> other if true. Examples use std::cmp::Ordering; assert_eq!(5.cmp(&10), Ordering::Less); assert_eq!(10.cmp(&5), Ordering::Greater); assert_eq!(5.cmp(&5), Ordering::Equal);
method core Stable since 1.0.0 Version 1.100.0-nightly
manishearth.github.io
...enum Foo { Str(String), Bool(bool) } let foo = Foo::Bool(true); // "pattern matching" match foo { Str(s) => /* do something with string `s` */, Bool(b) => /* do something with bool `b` */, } Swift is similar, and also calls them enums enum Foo { case str(String) case boolean(bool) } let foo = Foo.boolean(true...
News & Blog Posts 2017-03-07 ~9 min read
doc.rust-lang.org
...valid in the following conditions as well as the consequent block. • match arms bindings are within the match guard and the match arm expression. • match guard let bindings are valid in the following guard conditions and the match arm expression. Local variable scopes do not extend into item declarations. Pattern...
The Rust Reference Book 2024-01-01 ~8 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
animaomnium.github.io
...In the long run, I think that pattern-matching on structured data is a much cleaner and less error-prone route. The issue of deeply-nested pattern-matching can be resolved with a little sugar (e.g. do/with/use notation in Haskell/Koka/Gleam): there’s no reason not...
Observations/Thoughts 2023-04-19 ~3 min read
doc.rust-lang.org
...We’ll also define a new function to match the new function defined on Box<T>. We define a struct named MyBox and declare a generic parameter T because we want our type to hold values of any type. The MyBox type is a tuple struct with one element of...
The Rust Programming Language Book 2024-02-01 ~9 min read
"It's been 7.5 years since [#27060 ](https://github.com/rust-lang/rust/issues/27060) was reported, but the problem is finally fixed for good. :‍)"

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.