developerlife.com
...fn main() {
let args = args().collect::<Vec<String>>();
with(run(args), |it| match it {
Ok(()) => exit(0),
Err(err) => {
eprintln!("{}: {}", style_error("Problem encountered"), err);
exit(1);
}
});
}
fn run(args: Vec<String>) -> Result<(), Box<dyn Error>> {
match is_stdin_piped() {
true => piped_grep(PipedGrepOptionsBuilder::parse(args)?)?,
false => grep(GrepOptionsBuilder::parse...
Rust Walkthroughs
2023-05-17
~6 min read
casualhacks.net
Archived: primary link replaced with an archive on 2026-09-12T11:37:27.492Z (UTC; replacement date, not snapshot date)
...let x = match 42 {
_tmp1 => match foo!(_tmp1, arg) {
_tmp2 => baz!(_tmp2, a: 13)
}
};
Provide the evaluated self as the first argument (captured as an opaque expr fragment) to the macro and pass any additional tokens to the macro. This syntactic sugar is not to allow the macro to inspect...
Call for Blog Posts
2020-10-07
~7 min read
rustc-dev-guide.rust-lang.org
...Add your variant to the match in rustc_hir/attrs/encode_cross_crate.rs, which should return whether your attribute should be visible in dependent crates. This is usually No for code-gen related attributes, and Yes for analysis related attributes.
4. Create a new struct in rustc_attr_parsing...
Guide to Rustc Development
Book
2024-01-01
~4 min read
pzol.github.io
...let mut map = HashMap::<~str, uint>::new();
map.insert(~"foo", 1);
let s = match map.find(&~"foo") {
None => 0,
Some(v) => *v
};
As in get_copy you can use find_copy instead of find
let mut map = HashMap::<~str, uint>::new();
map.insert(~"foo", 1);
let r = match map.find...
Announcements, etc
2014-02-15
~6 min read
www.azabani.com
...It’s not a bad convention too — the unobtrusive dots for C0 controls and high bytes make ASCII text stand out, as if you had installed strings(1) on your pattern-matching neurons.
But imagine what kinds of patterns you could spot in binary data, if only there was a...
Project Updates
2020-11-18
~4 min read
fasterthanli.me
...15 | match dri {
| ^^^ pattern `&Juice` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `&Drink`
The compiler suggests two possible fixes, either add a wildcard:
fn print_drink(dri: &Drink) {
match dri {
Drink...
Learn More Rust
2020-09-09
~61 min read
blog.piston.rs
...Button::new()
.react(|event| match event {
button::Event::Pressed(mouse_button) => /* react to press, may get called multiple times */,
button::Event::Released(mouse_button) => /* react to release, may get called multiple times */,
button::Event::Clicked(mouse_button) => /* react to click, may get called multiple times */,
})
.set(ID, &mut ui);
There...
New Crates & Project Updates
2016-09-13
~9 min read
javierviola.com
...PlayerId = req.query().unwrap_or_default();
let state = req.state().clone();
let petnames = Petnames::default();
let player_id = match client.id {
Some( id ) => id,
None => petnames.generate_one(2, ".")
};
let player = Player {
id : PlayerId {id : Some(player_id.clone())},
wsc : wsc.clone(),
label: String::from("")
};
match state.add_player_to...
Rust Walkthroughs
2021-02-03
~11 min read
xnacly.me
...node[],
39 -- }
40 --```
41 --
42 hook = function(node)
43 if node.kind == "ident" then
44 if string.match(node.content, "%u") then
45 -- returing an error passes the diagnostic to sqleibniz,
46 -- thus a pretty message with the name of the hook, the
47 -- node it occurs and the message...
Observations/Thoughts
2024-12-25
~9 min read
rust-lang.github.io
...Note that this can only be done with a compiler that already supports i128/u128 to match the calling convention that LLVM is expecting.
Here is the list of functions that need to be implemented:
fn __ashlti3(a: i128, b: i32) -> i128;
fn __ashrti3(a: i128, b: i32) -> i128;
fn...
RFC 1504
RFC
2016-02-21
~4 min read
arxiv.org
...Among its design principles, Rust is aimed at matching C in terms of efficiency, but with increased code security and productivity. This paper presents a comparative study between C and Rust in terms of performance and programming effort, selecting as a case study the simulation of N computational bodies (N...
Research
2021-07-28
~1 min read
maguire.tech
...There’s a list of Users which are just uuid-name-hash combinations, and of Realms which can match on paths (there’s exact match, regex, etc) and then we can link together users and realms for authentication. For me, this system just makes sense.ConclusionThis project was a blast...
Project/Tooling Updates
2025-10-22
~9 min read
blog.darklang.com
...both OCaml and Rust are effectively using a pointer to another Expr.But what happens when we get to pattern matching? Well, here's how we do it in OCaml (full version here):(function
| state, [DList l; DBlock b] ->
let f (dv : dval) : dval = Ast.execute_dblock ~state b [dv...
Observations/Thoughts
2020-08-26
~15 min read
doc.rust-lang.org
...set_file_name` updates the file name of the `PathBuf`
new_path.set_file_name("package.tgz");
// Convert the `PathBuf` into a string slice
match new_path.to_str() {
None => panic!("new path is not a valid UTF-8 sequence"),
Some(s) => println!("new path is {}", s),
}
}
Be sure to...
Rust by Example
Book
2024-01-01
~1 min read
rust-lang-nursery.github.io
...Since command line input always arrives as plain text, custom types like LogLevel need a way to be matched against text. Deriving ValueEnum tells Clap which strings map to which variants, by default the lowercased variant names, so --log-level warn selects LogLevel::Warn. Any other value is rejected before...
The Rust Cookbook
Book
2024-01-01
~1 min read
mitchgollub.com
...body);
Ok(body)
}
}
/// Parses HTTP method codes from the Lambda Event
fn parse_http_method(input_method: &str) -> Method {
match input_method {
"GET" => Method::Get,
"POST" => Method::Post,
_ => panic!("No matching HTTP method for {}", input_method),
}
}
Source CodeMy source code is below! Feel free to use it as a template...
Rust Walkthroughs
2021-06-23
~3 min read
treit.github.io
...let opt = s.get(1..1000);
match opt {
Some(slice) => println!("{} - {}", s, slice),
None => println!("Did not produce a slice!"),
}
}
This illustrates two possible ways (if let and match) of pattern matching on an Option result and extracting the result, if any.
Declarative coding fun with iterators
We have examined...
News & Blog Posts
2020-03-17
~12 min read
jdrouet.github.io
...If we insert Alice, then searching alice won't find it, it's only exact match. This is good for matching email addresses, folder names, etc. The text index, on the opposite, the input data gets processed, but we'll talk about it right after.Once again, we can follow...
Rust Walkthroughs
2025-04-02
~18 min read
julienblanchard.com
...vec!["user@example.com".to_owned()] };
match enqueue(job) {
Ok(job) => println!("Enqueued job: {:?}", job),
Err(_) => { }
}
}
Figure 2: Resque screenshot
Great! We successfully enqueued a job that can be performed through
Resque.
Now onto the perform part.
News & Blog Posts
2015-11-02
~1 min read
doc.rust-lang.org
...Migration
The rust_2024_guarded_string_incompatible_syntax lint will identify any tokens that match the reserved syntax, and will suggest a modification to insert spaces where necessary to ensure the tokens continue to be parsed separately.
The lint is part of the rust-2024-compatibility lint group which is...
The Rust Edition Guide
Book
2024-01-01
~1 min read