rustc-dev-guide.rust-lang.org
...Examples of such structures include but are not limited to
• Parenthesis
• Removed without replacement, the tree structure makes order explicit
• for loops
• Converted to match + loop + match
• Universal impl Trait
• Converted to generic arguments (but with some flags, to know that the user didn't write them)
• Existential impl Trait...
Guide to Rustc Development
Book
2024-01-01
~2 min read
cantrip.org
...On earlier versions of the Rust compiler, I had to use an iterator pipeline, using .scan(), match, .filter(), and .collect(), at twice the line count, to get tolerable performance. Now the loop is faster. A match would work here, but the code would be longer. Rust could have just one...
News & Blog Posts
2016-02-01
~13 min read
dev.to
...A match has to cover every possible case and yours misses one.
error[E0004]: non-exhaustive patterns: `Direction::South` not covered
--> src/main.rs:8:11
|
8 | match d {
| ^ pattern `Direction::South` not covered
|
note: `Direction` defined here
--> src/main.rs:1:6
|
1 | enum Direction {
| ^^^^^^^^^
2 | North,
3 | South...
Rust Walkthroughs
2026-08-26
~14 min read
blog.urth.org
...Then it generates a CSS file containing just those strings
which match actual Tailwind names.But this scanning process, because it matches so broadly, errs on the side of false positives, and
the tailwindcss program will not emit any warnings when it finds a string that could be a match...
Rust Walkthroughs
2022-02-23
~16 min read
esimmler.com
...DomainType<T>,
{
match val {
Val::Var(var) => {
let resolved = self.domain.values_as_ref().get(var);
match resolved {
// We found another Var, try to resolve deeper
Some(found) => self.resolve_val(found),
// We didn't find a binding, return the Var
None => val,
}
}
// This isn't a Var, just return...
News & Blog Posts
2020-07-14
~6 min read
dev.to
...This method makes sure that the mock server received exactly one HTTP request that matched all the mock requirements. If not, it will fail the test with a detailed problem description (see next section).
Verification
Mock objects provide an assert method which ensures our app did actually send a request...
Rust Walkthroughs
2020-11-04
~6 min read
www.justanotherdot.com
...macro_rules! time {
($val:expr) => {
{
let beg = std::time::Instant::now();
match $val {
tmp => {
let end = std::time::Instant::now();
let time = (end - beg);
println!("[{}:{}] `{}' took {:?}", std::file!(), std::line!(), std::stringify!($val), time);
tmp
}
}
}
};
($($val:expr),+ $(,)?) => {
($(time!($val)),+,)
};
}
This change uses the repeat pattern matches of macros to consistently...
Observations/Thoughts
2020-08-26
~4 min read
system76.com
...System76 offers health benefits, paid vacation, matching 401k, sabbatical, and an awesome dog-friendly work environment where smart people are free to create.
We are committed to providing equal employment opportunities to all employees and applicants, regardless of race, color, creed, religion, sex, gender identity/expression, age, national origin, disabilities...
Rust Jobs
2019-01-08
~1 min read
rauljordan.com
...Match statements are very flexible and structural in nature
Instead of nesting match statements, for example, one could bring values together as tuples and do
the following:
fn player_outcome(player: &Move, opp: &Move) -> Outcome {
use Move::*;
use Outcome::*;
match (player, opp) {
// Rock moves.
(Rock, Rock) => Draw,
(Rock, Paper) => Lose...
Rust Walkthroughs
2023-01-25
~26 min read
matklad.github.io
...u32,
) -> io::Result<Option<Widget>> {
let key = id.to_be_bytes();
let value = match self.db.load(&key)? {
None => return Ok(None),
Some(it) => it,
};
let widget: Widget =
bincode::deserialize(&value).map_err(|it| {
io::Error::new(io::ErrorKind::InvalidData, it)
})?;
Ok(Some(widget))
}
}
Now, for the sake of argument...
Rust Walkthroughs
2022-06-15
~6 min read
thume.ca
...Instead of using data tables like in the canonical Pratt parser implementation, we used Rust functions with match statements, which fill the same purpose but with more power and no need to keep a data structure around:
fn binding_power(cur: &SpannedToken) -> Option<u8> {
match &cur.tok {
Token::Operator(op...
News & Blog Posts
2019-05-28
~15 min read
notes.iveselov.info
...if $s matched our tokens without trailing semicolon, won't it be logical to add that semicolon in the expansion part to compensate?The reason that it doesn't work like that is as follows. When we expand the macro, matched $s is not a token stream anymore! Since its...
News & Blog Posts
2020-05-12
~6 min read
system76.com
...System76 offers health benefits, paid vacation, matching 401k, sabbatical, and an awesome dog-friendly work environment where smart people are free to create.
We are committed to providing equal employment opportunities to all employees and applicants, regardless of race, color, creed, religion, sex, gender identity/expression, age, national origin, disabilities...
Rust Jobs
2020-06-10
~1 min read
poignardazur.github.io
...foobar(my_a, my_b);
The type system takes the types of my_a and my_b, and finds the least restrictive qualifier that matches both these types. inout becomes that qualifer.
For instance, if my_a is const int* and my_b is int*, inout “becomes” const, and the...
Observations/Thoughts
2022-01-12
~4 min read
rustc-dev-guide.rust-lang.org
...Prefer exhaustive matches
Using _ in a match is convenient, but it means that when new variants are added to the enum, they may not get handled correctly. Ask yourself: if a new variant were added to this enum, what's the chance that it would want to use the _ code...
Guide to Rustc Development
Book
2024-01-01
~4 min read
rust-analyzer.github.io
...true
#3580 macro expander is now more tolerant for syntax errors, which makes code completion inside macros more robust.
#3623 Fill Match Arms assist now works even if some arms are already present.
#3607 and instructions for installing rust-analyzer from AUR.
#3640, #3651 assist to merge imports with a...
News & Blog Posts
2020-03-24
~1 min read
www.rsarai.xyz
...use std::path::Path;
use std::fs::File;
use std::io::prelude::*;
fn load_documents(path_str: &str) {
// Create a path to the desired file
let path = Path::new(&path_str);
let display = path.display();
// Open the path in read-only mode, returns `io::Result<File>`
let mut file = match...
Rust Walkthroughs
2022-05-18
~7 min read
rust-analyzer.github.io
#9936 (first contribution) make compiler commit and date optional in proc macros.
#9962 (first contribution) improve "Replace match with if let" code generation.
#9963 resolve core::arch module.
#9973, #9988 refactor and improve handling of overloaded binary operators.
#9943 don’t strip items with built-in attributes.
#9976 hide functional...
Project/Tooling Updates
2021-08-25
~1 min read
aminediro.com
...Traditionally, text search is usually done using some kind of exact matching or fuzzy matching algorithm with some sprinkled clever pre/post processing techniques like stemming, and lemmatization… All it can do is to check, at scale, whether a query matches some text and return the result. The big downside...
Observations/Thoughts
2024-01-17
~17 min read
rust-lang-nursery.github.io
...use std::time::Duration;
use tokio::time::timeout;
async fn fetch_network_request() -> u32 {
89
}
#[tokio::main]
async fn main() {
match timeout(Duration::from_millis(5), fetch_network_request()).await {
Ok(x) => println!("Received {x}"),
Err(_) => eprintln!("Timed Out!"),
}
}
Add tokio to Cargo.toml with the macros and time features...
The Rust Cookbook
Book
2024-01-01
~1 min read