doc.rust-lang.org
pub fn connect<P>(&self, path: P) -> io::Result<()>
...Examples
use std::os::unix::net::UnixDatagram;
fn main() -> std::io::Result<()> {
let sock = UnixDatagram::unbound()?;
match sock.connect("/path/to/the/socket") {
Ok(sock) => sock,
Err(e) => {
println!("Couldn't connect: {e:?}");
return Err(e)
}
};
Ok(())
}
method
std
Stable since 1.10.0
Version 1.100.0-nightly
github.com
...Attribute
invocations can only match the `attr` rules, and non-attribute invocations can
only match the non-`attr` rules. This allows adding `attr` rules to an existing
macro without breaking backwards compatibility.
An attribute macro may emit code containing another attribute, including one
provided by an attribute macro. An attribute...
RFC 3697
RFC
2024-09-20
~8 min read
blog.none.at
...If the target returns both the HTML element and the cookie on every single response, the iteration count, HTML match count, and header match count should be identical — any mismatch indicates a parsing or check evaluation bug:=== per-worker results ===
worker iterations html_match header_match ok?
-------------------------------------------------------------------------------------
http://worker1:9091...
Project/Tooling Updates
2026-03-18
~25 min read
matklad.github.io
...Repr::Custom(Box::new(Custom { kind, error })),
}
}
pub fn get_ref(
&self,
) -> Option<&(dyn error::Error + Send + Sync + 'static)> {
match &self.repr {
Repr::Os(..) => None,
Repr::Simple(..) => None,
Repr::Custom(c) => Some(&*c.error),
}
}
pub fn into_inner(
self,
) -> Option<Box<dyn error::Error + Send + Sync>> {
match self.repr {
Repr...
Observations/Thoughts
2020-10-21
~8 min read
github.com
...Features:
+ perf Enables all performance related features
+ perf-dfa Enables the use of a lazy DFA for matching
+ perf-inline Enables the use of aggressive inlining inside
match routines
+ perf-literal Enables the use of literal optimizations for
speeding up matches
+ std When enabled, this will cause regex to use...
RFC 3416
RFC
2023-04-14
~4 min read
44:28
Rustacean Station
rustacean-station.org
Episode: What's New in Rust 1.54 and 1.55
...uh open range patterns in match statements the idea is that if you match on say an integer you can say i
want to match on zero to four and then i want to match on five and above previously you could always
match on ranges but only if they...
Podcast
2021-10-25
44:28
github.com
...eprintln!("[{}:{}] {} = {:#?}", file!(), line!(), stringify!($expr), &expr);
expr
}
}
}
}
```
The use of `match` over `let` is similar to the implementation of `assert_eq!`.
It [affects the lifetimes of temporaries](
https://stackoverflow.com/questions/48732263/why-is-rusts-assert-eq-implemented-using-a-match#comment84465322_48732525).
## Drawbacks
[drawbacks]: #drawbacks
Adding to the prelude...
RFC 2361
RFC
2018-03-13
~8 min read
fredrik.anderzon.se
...Knock, knock", fruits[i]);
println!("WHO'S THERE???");
},
3 => {
println!("{}", fruits[i]);
println!("{}, who?", fruits[i]); },
4 => {
println!("{} you glad I didn't say {}?", fruits[i], fruits[0]);
println!("facepalm");
},
// Rust wants to make sure your match statements always get a match to avoid
// unexpected behaviors, `_` is the "default" or...
News & Blog Posts
2016-05-16
~19 min read
datafusion.apache.org
...It handles schema differences in file scans by rewriting expressions to match the physical schema, including type casting, missing columns, and partition values. For detailed documentation, see the PhysicalExprAdapter trait documentation. Most projects should use the datafusion crate directly, which re-exports this module. If you are already using the...
Crate
v55.0.0
2026-08-18
doc.rust-lang.org
pub fn back_mut(&mut self) -> Option<&mut T>
...Examples
use std::collections::LinkedList;
let mut dl = LinkedList::new();
assert_eq!(dl.back(), None);
dl.push_back(1);
assert_eq!(dl.back(), Some(&1));
match dl.back_mut() {
None => {},
Some(x) => *x = 5,
}
assert_eq!(dl.back(), Some(&5));
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn front_mut(&mut self) -> Option<&mut T>
...Examples
use std::collections::LinkedList;
let mut dl = LinkedList::new();
assert_eq!(dl.front(), None);
dl.push_front(1);
assert_eq!(dl.front(), Some(&1));
match dl.front_mut() {
None => {},
Some(x) => *x = 5,
}
assert_eq!(dl.front(), Some(&5));
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn as_mut(&mut self) -> Result<&mut T, &mut E>
...Examples
fn mutate(r: &mut Result<i32, i32>) {
match r.as_mut() {
Ok(v) => *v = 42,
Err(e) => *e = 0,
}
}
let mut x: Result<i32, i32> = Ok(2);
mutate(&mut x);
assert_eq!(x.unwrap(), 42);
let mut x: Result<i32, i32> = Err(13);
mutate(&mut x);
assert_eq!(x...
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct UnixListener
...UnixStream) {
// ...
}
fn main() -> std::io::Result<()> {
let listener = UnixListener::bind("/path/to/the/socket")?;
// accept connections and process them, spawning a new thread for each one
for stream in listener.incoming() {
match stream {
Ok(stream) => {
/* connection succeeded */
thread::spawn(|| handle_client(stream));
}
Err(err) => {
/* connection failed */
break;
}
}
}
Ok(())
}
struct
std
Stable since 1.10.0
Version 1.100.0-nightly
docs.rs
...Lastly, Radium provides RadiumT type aliases matching all of the AtomicT type names in the standard library. Each of these aliases forwards to its atomic variant when it exists, and to Cell<T> when it does not. Your code can use these names to be portable across targets with varying...
Crate
v1.1.1
2025-07-09
substrate.dev
...Search for a matching entry that has matching key bits. Use the address in the entry to query the partial k and value from a value table. Confirm that k matches expected value. Hash index insertion If an insertion is attempted into a full index page a reindex is triggered...
Crate
v0.5.6
2026-07-20
upsuper.github.io
...matches (Pattern) -> &strfn trim_start_matches (Pattern) -> &strfn trim_end_matches (Pattern) -> &strMatching and findingfn contains (Pattern) -> boolfn starts_with (Pattern) -> boolfn ends_with (Pattern) -> boolfn find (Pattern) -> Option<usize>fn rfind (Pattern) -> Option<usize>fn matches (Pattern) -> Iterator<Item = &str>fn rmatches (Pattern) -> Iterator<Item = &str>fn match_indices...
News & Blog Posts
2019-04-30
~8 min read
home.expurple.me
Table of Contents“Using thiserror for libraries and anyhow for applications”Pattern matching isn’t the only reason to use structured errorsThe tradeoffsTo be continuedRelated readingDiscussTL;DR I prefer thiserror enums over anyhow, even for application code that
simply propagates errors. Custom error types require additional effort, but make
the...
Observations/Thoughts
2025-06-04
~8 min read
www.freecodecamp.org
...In main let's check that the action passed as an argument is "complete" by using an else if statement:
// in the main function
if action == "add" {
// add action snippet
} else if action == "complete" {
match todo.complete(&item) {
None => println!("'{}' is not present in the list", item),
Some(_) => match todo...
Rust Walkthroughs
2021-01-06
~22 min read
blog.veeso.dev
...Option<Vec<(ColumnDef, Value)>>, op: &Operation,) -> Option<Vec<(ColumnDef, Value)>> { match (row, op) { (_, Operation::Insert(_, record)) => Some(record.clone()), (_, Operation::Delete(_)) => None, (None, Operation::Update(_, _)) => None, (Some(mut existing_row), Operation::Update(_, updates)) => { for (col_name, new_value) in updates { if let Some((_, value)) = existing_row .iter_mut() .find(|(col...
Observations/Thoughts
2025-12-10
~6 min read
swatinem.de
...for item in iter {
let item = match item {
Ok(item) => item,
Err(_) => break,
};
// ...
}
// or we can skip over errors:
for item in iter {
let item = match item {
Ok(item) => item,
Err(_) => continue,
};
// ...
}
// or even simpler, since `Result` implements `IntoIterator`:
for item in iter.flatten() {
// ...
}
We can also directly collect this...
Observations/Thoughts
2022-07-13
~4 min read