casualhacks.net
...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
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
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
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
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
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
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
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
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
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
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
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
github.com
...when a target modifier
changes), and that match the user's profile.
These proposals are drafts and are intended only to signpost future direction
for this feature, and ensure compatibility with the current proposal:
- [`build-std.when = "compatible"`][build-std-part-four-draft]
- [`build-std.when = "match-profile"`][build-std...
RFC 3874
RFC
2025-06-05
~50 min read
vitiral.github.io
...Many of the concepts that rust taught such as
expressions returning a value
and pattern matching
were utilized for exactly the same benefit in elm.
A frontend in elm with a backend in rust is a match made in heaven: fun,
performant and safe.
Rust web development
Before I got...
News & Blog Posts
2016-12-13
~4 min read
dhruv-ahuja.github.io
...Operation) {
let is_empty = queue.len() == 0;
let is_full = queue.len() == self.capacity;
match operation {
Operation::Push { mut is_full_flag } => {
let mut is_empty_flag = self.is_empty.lock().unwrap();
if *is_empty_flag {
*is_empty_flag = false;
println!("set is_empty to false");
self.is_empty_signal...
Rust Walkthroughs
2023-09-06
~9 min read
greptime.com
...ident) => {
paste! {
fn [<eval_ $O>](columns: &[VectorRef]) -> Result<VectorRef> {
with_match_primitive_type_id!(columns[0].data_type().logical_type_id(), |$S| {
with_match_primitive_type_id!(columns[1].data_type().logical_type_id(), |$T| {
with_match_primitive_type_id!(columns[2].data_type().logical_type_id(), |$R| {
// clip(a...
Rust Walkthroughs
2025-11-26
~14 min read