dev.to
...After seeing '*', we try to match the rules, and find that it can be matched with First rule of Factor, knowing that '2' is an Factor, we can reduce '2*3' as '6', which is classified as an Factor again. After seeing '/' we try to find the rule, match with...
Learn Simple Rust
2020-10-14
~7 min read
mainmatter.com
...message
}]
});
let client = Client::new();
let result = client
.post("https://api.sendgrid.com/v3/mail/send")
.header("Authorization", format!("Bearer {}", api_key))
.header("Content-Type", "application/json")
.body(data)
.send()
.await;
match result {
Ok(response) => match response.status() {
202 => Response::ok(""),
_ => Response::error("Bad Gateway", 502),
},
Err(_) => Response::error("Internal...
Rust Walkthroughs
2022-12-14
~8 min read
blog.nodebb.org
...let mut res = Vec::new();
let mut index = 0; while index < input.len() { match sep.parse(input.slice(index..)) { Err(nom::Err::Error(_)) => { // do-while while { index += 1; !input.is_char_boundary(index) } {} } Err(e) => return Err(e), Ok((rest, mat)) => { // if this match was escaped, skip it if input...
Observations/Thoughts
2020-11-25
~16 min read
llogiq.github.io
...We can get rid of those if we encode our atoms as empty
enums by relying on the fact that an empty match {} matches all possible
values of an empty enum. So if we have
enum Foo {}
we can write
impl<B: Bar> Add<B> for Foo {
type Output = ...;
fn...
News & Blog Posts
2016-02-29
~2 min read
dev.to
...The body syntax is similar to match guard, the Rust equivalent to switch-case statement. This guard is slightly different since it is matching against Rust code. It has one arm in parenthesis ( $( $x:expr),* ) which represents a pattern. If the pattern matches, the code after => will be executed.
In...
Learn More Rust
2020-09-23
~9 min read
www.riskpeep.com
...18 - Match on the distance from the player.
19-38 - Arms for each of the distances that an object can be. Respond appropriately for each.
39-42 - This arm should never be matched. Unknown objects will be matched on 25, and other known objects will be matched on 32.
Contents...
Rust Walkthroughs
2023-02-22
~25 min read
fathy.fr
...Google recommending me Chrome, lolfor &key in input {
sequence = match sequence {
Sequence::Char => match key {
0x1b => Sequence::Escape,
0x03 => emit!(Event::Exit),
key => emit!(Event::KeyPress { key }),
},
Sequence::Escape => match key {
b'[' => Sequence::Control,
b'P' => Sequence::DeviceControl(DeviceControl::new()),
0x1b =>
emit!(Event::KeyPress { key: 0x1b }; continue),
key => {
emit!(Event...
Observations/Thoughts
2023-02-01
~12 min read
tvm.apache.org
...The match_any! macro matches the IR node type:
fn describe(expr: &PrimExpr) -> Result<String> {
let text = match_any! {
expr {
Add(ref add) => format!("({} + {})", describe(&add.a)?, describe(&add.b)?),
Mul(ref mul) => format!("({} * {})", describe(&mul.a)?, describe(&mul.b)?),
Var(ref var) => var.name.as_str().to_owned(),
IntImm...
Project/Tooling Updates
2026-11-18
~15 min read
osblog.stephenmarz.com
...That is why with print, we specify the plus '+', so that we match ONE or more. To match ZERO or more, we would use the asterisk '*'.
The second arm has $fmt:expr, which Rust will match if we provide at least one argument. In this case, this is the format...
News & Blog Posts
2019-10-15
~26 min read
kamalmarhubi.com
...Rust has a pattern matching syntax for easily checking which variant an enum value is. If we have a variable fork_result, we can pattern match on it like this:
match fork_result {
ForkResult::Parent { child } => {
// stuff to do if we're in the parent
}
ForkResult::Child => {
// stuff do do...
Notable New Crates & Project Updates
2016-04-25
~9 min read
blog.servo.org
...emilio replaced many ad-hoc checks in the CSS selector matching with more structured and consistent logic.
rlhunt added support for tiling gradients in WebRender.
mrobinson improved the logic for deciding when to clip content.
stshine made text correctly inherit overflow properties from its parent element.
nox shared more code...
News & Blog Posts
2017-04-11
~1 min read
nbaksalyar.github.io
...match token {
SERVER_TOKEN => {
...
}
}
What does it mean? Well, the match syntax resembles the standard switch construct you can find in “traditional” imperative languages, but it has a lot more power to it. While in e.g. Java switch can match only on numbers, strings, and enums, Rust’s match...
From the Blogosphere
2015-07-13
~35 min read
dev.to
...HttpRequest) -> impl Responder {
let name = req.match_info().get("name").unwrap();
let resp = format!("hello {}", name);
HttpResponse::Ok().body(resp)
}
Enter fullscreen mode
Exit fullscreen mode
We get the name value from req's match info, then format the return string and return the response.
Now visit http://127.0...
Learn More Rust
2020-08-26
~4 min read
doc.rust-lang.org
...Fields of tuples are named using increasing numeric names matching their position in the list of types. The first field is 0. The second field is 1. And so on. The type of each field is the type of the same position in the tuple's list of types.
For...
The Rust Reference
Book
2024-01-01
~1 min read
woodruff.dev
...What to Expect
Real comparisons between Rust and C#
Lessons on ownership, pattern matching, traits, and lifetimes
Daily reflections from a .NET developer mindset
Daily Breakdown
Day 1: Why Rust? A C# Developer’s Journey Begins
Day 2: Installing Rust: From dotnet new to cargo new
Day 3: Hello, World...
Miscellaneous
2025-05-21
~2 min read
tndl.me
...mismatched types expected `bool`, found `&str`
}
Switch & Match
Switch statements aren't as widely used in JavaScript as if/else, but match statements in Rust are very popular. They aren't exactly the same, and match statements have a lot of powerful uses not available to JavaScript switch statements.
// JavaScript...
Learn Standard Rust
2020-08-26
~4 min read
featherweightmusings.blogspot.co.nz
...Expr) { match e { Add(x, y) => println!("An `Add` variant: {} + {}", x, y), Or(..) => println!("An `Or` variant"), _ => println!("Something else (in this case, a `Lit`)"), }}
Each arm of the match expression matches a variant of `Expr`. All variants must be covered. The last case (`_`) covers all remaining variants, although in...
Community Updates
2014-05-24
~9 min read
blog.burntsushi.net
...use bstr::ByteSlice;
fn main() {
let haystack = b"foo bar foo\xFF\xFFfoo quux foo";
let mut matches = vec![];
for start in haystack.find_iter("foo") {
matches.push(start);
}
assert_eq!(matches, [0, 8, 13, 22]);
}
This makes use of the ByteSlice::find_iter method. Unlike the
standard library, bstr...
Project/Tooling Updates
2022-09-14
~40 min read
c410-f3r.github.io
...When Client 2 connects, the previous matching entry is removed and a new chat is established through the insertion of each client ID into the messages collection. A new chat also triggers the awakening of the matching client (Client 1) finally returning the remote ID.
Remember when you heard that...
Rust Walkthroughs
2024-12-04
~11 min read
mercurialsolo.github.io
...The rules engine lets you define declarative policies in .claudectl.toml:[[rules]]
name = "auto-approve-tests"
match_status = ["NeedsInput"]
match_tool = ["Bash"]
match_command = ["cargo test", "npm test"]
match_project = ["api-server"]
action = "approve"
[[rules]]
name = "kill-expensive"
match_cost_above = 10.0
action = "terminate"
All conditions within a rule...
Rust Walkthroughs
2026-04-15
~11 min read