doc.rust-lang.org
pub const fn as_mut(&mut self) -> Option<&mut T>
Option::as_mut — Converts from &mut Option<T> to Option<&mut T>.
Examples
let mut x = Some(2);
match x.as_mut() {
Some(v) => *v = 42,
None => {},
}
assert_eq!(x, Some(42));
method
core
Stable since 1.0.0
Version 1.100.0-nightly
vishpat.github.io
...Rust's rich programming constructs such as enum, pattern matching, and error handling make it easy and a joy to implement this bare-bone interpreter.
Pre-requistes
To make the most out of this project, it is expected that the user is aware of the following Computer Science concepts
Lists...
Observations/Thoughts
2022-05-11
~2 min read
pitsidianak.is
...Instruction: {instruction:?}")
}};
}
match op {
Op::ORR => {
// Bitwise OR
// This instruction performs a bitwise (inclusive) OR of a register value and an
// immediate value, and writes the result to the destination register.
let target = match instruction.operands()[0] {
bad64::Operand::Reg {
ref reg,
arrspec: None,
} => *self.reg_to_var(reg, true...
Observations/Thoughts
2025-08-27
~10 min read
docs.rs
...ListTablesInput = Default::default(); match client.list_tables(list_tables_input).await { Ok(output) => match output.table_names { Some(table_name_list) => { println!("Tables in database:"); for table_name in table_name_list { println!("{}", table_name); } } None => println!("No tables in database!"), }, Err(error) => { println!("Error: {:?}", error); } } } Usage with rustls If...
Crate
v0.48.0
2022-04-25
doc.rust-lang.org
pub fn connect<P>(path: P) -> io::Result<UnixStream>
UnixStream::connect — Connects to the socket named by path.
Examples
use std::os::unix::net::UnixStream;
let socket = match UnixStream::connect("/tmp/sock") {
Ok(sock) => sock,
Err(e) => {
println!("Couldn't connect: {e:?}");
return
}
};
associated_function
std
Stable since 1.10.0
Version 1.100.0-nightly
docs.rs
...The API version for the given message matching the version specified in the request header must be provided. use bytes::BytesMut; use kafka_protocol::messages::MetadataRequest; use kafka_protocol::protocol::Encodable; let mut bytes = BytesMut::new(); let request = MetadataRequest::default(); request.encode(&mut bytes, 12).unwrap(); Deserialization Messages can be...
Crate
v0.18.0
2026-08-20
docs.rs
...this is the generic case when we don't know about the input BufRead. // when the input is a &str or a &[u8], we don't actually need to use another // buffer, we could directly call `reader.read_event()` match reader.read_event_into(&mut buf) { Err(e) => panic!("Error...
Crate
v0.42.0
2026-08-22
blog.warp.dev
...SplitDirection,
) -> bool {
match self {
PaneNode::Leaf(session) => {
if *session == old_session {
*self = PaneNode::Branch(PaneBranch::new(old_session, new_session, direction));
true
} else {
false
}
}
PaneNode::Branch(branch) => branch.split(old_session, new_session, direction),
}
}
fn remove(&mut self, session_id: EntityId) -> bool {
match self {
// Leaves can only be removed from...
Rust Walkthroughs
2022-01-26
~11 min read
rust-gcc.github.io
...Zhi Heng’s work is allowing us to handle some
complex pattern matches present in core, which the compiler would
previously ignore - while Ryutaro’s contributions are adding more
complex warning checkers while removing previous false positives. Thanks
to them, the compiler is getting more correct, and gets closer and...
Project/Tooling Updates
2025-08-06
~11 min read
www.lpalmieri.com
...Expected range of matching incoming requests: == 1
Number of matched incoming requests: 0
'
Why is that?
Let's add a dbg! statement to our matcher to inspect the incoming request:
//! src/email_client.rs
// [...]
#[cfg(test)]
mod tests {
// [...]
impl wiremock::Match for SendEmailBodyMatcher {
fn matches(&self, request: &Request) -> bool {
// [...]
if...
Rust Walkthroughs
2021-01-20
~41 min read
arzg.github.io
...How is the parser meant to manage expected_kinds if it can’t know which arm of the match is being run and which ones have been tried before? We’ll have to convert all these matches to if else chains that use Parser::at.To ensure we don’t...
Rust Walkthroughs
2020-12-23
~30 min read
arzg.github.io
...First, we’ll determine which particular operator we’re looking at:pub(super) fn expr(p: &mut Parser) {
match p.peek() {
Some(SyntaxKind::Number) | Some(SyntaxKind::Ident) => p.bump(),
_ => {}
}
let op = match p.peek() {
Some(SyntaxKind::Plus) => Op::Add,
Some(SyntaxKind::Minus) => Op::Sub,
Some(SyntaxKind::Star) => Op::Mul,
Some...
Rust Walkthroughs
2020-11-18
~27 min read
vincents.dev
...std::num::ParseIntError) -> Self {
DemoError::ParseErr(error)
}
}
impl Error for DemoError {}
impl Display for DemoError {
fn fmt(&self, f: &mut Formatter) -> Result<(), std::fmt::Error> {
match self {
DemoError::ParseErr(error) => write!(
f,
"error parsing with {}", error.to_string()
),
}
}
}
fn my_function() -> Result<(), DemoError> {
let first_input = "3^";
let my_number...
Rust Walkthroughs
2025-12-31
~9 min read
arzg.github.io
...We should also define a proper format for displaying Vals so we can customise how they appear:// crates/eldiro/src/val.rs
use std::fmt;
// snip
impl fmt::Display for Val {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Number(n) => write!(f, "{}", n),
Self::Unit...
Learn More Rust
2020-10-07
~13 min read
FOSDEM
archive.fosdem.org
...These guarantees are not formally specified, which makes it harder to reason about the safety of the wrapped unsafe logic; this issue is compounded by the fact that undefined behaviour can seep into safe rust from unsafe code that doesn't match rust's expected semantics. I'll discuss how...
Talk
Andrea Lattuada
2019-02-02
danube-docs.dev-state.com
...Pattern
Matches
"payment"
Exact match only
"ship*"
"shipping", "shipment", etc.
"eu-west-?"
"eu-west-1", "eu-west-2", etc.
"*"
Everything (same as no filter)
Glob matching is implemented with an iterative backtracking algorithm (simple_glob) that handles * and ? without regex overhead.
If a message's routing key matches no consumer...
Project/Tooling Updates
2026-04-22
~8 min read
timryan.org
...But we
lack one important aspect of Rust’s pattern matching capabilities: its
requirement that all match arms must be “exhaustive” (that is, there are no
unhandled cases).
If we matched against the FrontendMessage enum type, but we only handled the
Init and ButtonState variants, our program would fail at...
News & Blog Posts
2019-01-29
~9 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
cglab.ca
...Ord, V> Map<K, V> for BTreeMap<K, V> {
fn find(&self, key: &K) -> Option<&V> {
let mut cur_node = &self.root;
loop {
match cur_node.search(key) {
Found(i) => return cur_node.val(i),
GoDown(i) => match cur_node.edge(i) {
None => return None,
Some(next_node) => {
cur_node...
Observations/Thoughts
2021-02-03
~35 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