github.com
...The compiler's searching and file matching logic would be altered to only match
crates based on name. If two versions of a crate are found, the compiler will
unconditionally emit an error. It will be up to the user to move the two
libraries on the filesystem and control...
RFC 109
RFC
2014-06-24
~7 min read
fitzgeraldnick.com
...bz_stream = mem::zeroed();
let result = BZ2_bzCompressInit(&mut stream as *mut _,
1, // 1 x 100000 block size
4, // verbosity (4 = most verbose)
0); // default work factor
match result {
r if r == (BZ_CONFIG_ERROR as _) => panic!("BZ_CONFIG_ERROR"),
r if r == (BZ_PARAM_ERROR as _) => panic!("BZ_PARAM...
News & Blog Posts
2016-12-20
~9 min read
dev.to
...Self::Message) -> ShouldRender {
match msg {
Msg::Increment => self.value += 1,
Msg::Decrement => self.value -= 1,
}
true
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
false
}
fn view(&self) -> Html {
html! {
<div>
<button onclick=self.link.callback(|_| Msg::Increment)>{"+"}</button>
<span style="width: 50px">{ self.value }</span>
<button onclick=self.link...
Rust Walkthroughs
2020-11-25
~5 min read
jorgeortiz.dev
...So we used the matches!() macro inside the assertion to verify this use
case. The expression used was assert!(matches!(...));, that is not as clarifying as it could be.
I have used similar expressions for quite a while, but I was secretly hoping that assert_matches!() would become part
of...
Rust Walkthroughs
2025-11-19
~13 min read
www.joshmcguigan.com
...fn main(){
loop {
print!("> ");
stdout().flush();
let mut input = String::new();
stdin().read_line(&mut input).unwrap();
let mut parts = input.trim().split_whitespace();
let command = parts.next().unwrap();
let args = parts;
match command {
"cd" => {
// default to '/' as new directory if one was not provided
let new_dir = args.peekable...
News & Blog Posts
2018-11-20
~7 min read
arzg.github.io
...SyntaxNode) -> Option<Self> {
let result = match node.kind() {
SyntaxKind::InfixExpr => Self::BinaryExpr(BinaryExpr(node)),
SyntaxKind::Literal => Self::Literal(Literal(node)),
SyntaxKind::ParenExpr => Self::ParenExpr(ParenExpr(node)),
SyntaxKind::PrefixExpr => Self::UnaryExpr(UnaryExpr(node)),
SyntaxKind::VariableRef => Self::VariableRef(VariableRef(node)),
_ => return None,
};
Some(result)
}
}
We’re still missing an AST node, namely...
Rust Walkthroughs
2021-01-27
~21 min read
sabrinajewson.org
...We have to match on the Result for that:let blocks = match Blocks::from_file("Blocks.txt") {
Ok(blocks) => blocks,
Err(unicode_blocks::Error::Io(e)) if e.kind() == io::ErrorKind::NotFound => {
}
};
Great! But the compiler is yelling that the match arms aren’t exhaustive. Not too hard to fix...
Observations/Thoughts
2023-04-12
~23 min read
rust-analyzer.github.io
Rust toolchains newer than 2022-07-29 contain a proc macro server that should be compatible with macros built by the matching compiler.
Since today’s release, the server is automatically detected by and used rust-analyzer.
This means that, from now on, proc macros will keep working when the...
Project/Tooling Updates
2022-08-03
~1 min read
danube-docs.dev-state.com
...Subsequent producers must use the same subject:
// First producer - assigns schema subject to topic
let first = client.producer()
.with_topic("new-topic")
.with_schema_subject("user-events") // ✅ Sets topic's schema
.build();
// Second producer - must match
let second = client.producer()
.with_topic("new-topic")
.with_schema_subject("user-events") // ✅ Matches...
Project/Tooling Updates
2026-01-07
~10 min read
llogiq.github.io
...enum variants, you can also use match, but keep it simple: Only match one thing, and avoid more complex things like guard clauses:
// Don't nest patterns in match arms
match err_opt_val {
Some(Err(e)) => panic!("{e}"),
_ => (),
}
// instead, nest `match` expressions
match err_opt_val {
Some(err_val...
Observations/Thoughts
2024-04-03
~16 min read
pythonspeed.com
...def assert_matches(counts1, counts2):
"""Match A to Z counts."""
for character in 'abcdefghijklmnopqrstuvwxyz':
assert counts1[character] == counts2[character]
assert_matches(
frequency_1(TEXT),
frequency_3(TEXT)
)
Our new implementation is even faster:
Code
Elapsed microseconds
frequency_2(TEXT)
25,965.5
frequency_3(TEXT)
19,443.5
The Practice...
Observations/Thoughts
2025-07-09
~14 min read
rreverser.com
...bool> MyEnum<AllowB> {
fn is_a(&self) -> bool {
match *self {
MyEnum::A => true,
_ => false,
}
}
}
impl MyEnum<true> {
// this won't be allowed on MyEnum<false>, giving a helpful compile-time error
fn is_b(&self) -> bool {
match *self {
MyEnum::B => true,
_ => false,
}
}
}
The first thing that comes to mind is...
News & Blog Posts
2018-01-02
~5 min read
thefuntastic.com
...This is what the match construct is all about: match item_option { Some(item) => { //Do something with resource println!("{}", item); } None => {}};It's called pattern matching and it's a switch statement, but for types. Here the Some branch is the only code path with a valid reference to item...
Observations/Thoughts
2020-10-28
~18 min read
github.com
...Only types which have the "structural match"
property can be used as const parameters. This would exclude floats, for
example.
The structural match property is intended as a stopgap until a final solution
for matching against consts has been arrived at. It is important for the
purposes of type equality...
RFC 2000
RFC
2017-05-01
~11 min read
github.com
...Usually, you'll want to copy this value from a corresponding `-fpatchable-function-entry=` being passed to the C compiler in your project - `total_nops` will match the first parameter used by your C compiler, and the optional `offset` parameter passed to the C compiler will match `prefix_nops`.
To...
RFC 3543
RFC
2023-12-12
~12 min read
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
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