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
...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
doc.rust-lang.org
pub const fn wrapping_shr(self, rhs: u32) -> Self
...Instead, the behaviour of this method matches what shift instructions do on many processors, and is what the >> operator does when overflow checks are disabled, but numerically it's weird. Consider, instead, using Self::unbounded_shr which has nicer behaviour.
Note that this is not the same as a rotate...
method
core
Stable since 1.2.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn wrapping_shr(self, rhs: u32) -> Self
...Instead, the behaviour of this method matches what shift instructions do on many processors, and is what the >> operator does when overflow checks are disabled, but numerically it's weird. Consider, instead, using Self::unbounded_shr which has nicer behaviour.
Note that this is not the same as a rotate...
method
core
Stable since 1.2.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn wrapping_shr(self, rhs: u32) -> Self
...Instead, the behaviour of this method matches what shift instructions do on many processors, and is what the >> operator does when overflow checks are disabled, but numerically it's weird. Consider, instead, using Self::unbounded_shr which has nicer behaviour.
Note that this is not the same as a rotate...
method
core
Stable since 1.2.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn wrapping_shr(self, rhs: u32) -> Self
...Instead, the behaviour of this method matches what shift instructions do on many processors, and is what the >> operator does when overflow checks are disabled, but numerically it's weird. Consider, instead, using Self::unbounded_shr which has nicer behaviour.
Note that this is not the same as a rotate...
method
core
Stable since 1.2.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn wrapping_shr(self, rhs: u32) -> Self
...Instead, the behaviour of this method matches what shift instructions do on many processors, and is what the >> operator does when overflow checks are disabled, but numerically it's weird. Consider, instead, using Self::unbounded_shr which has nicer behaviour.
Note that this is not the same as a rotate...
method
core
Stable since 1.2.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn wrapping_shr(self, rhs: u32) -> Self
...Instead, the behaviour of this method matches what shift instructions do on many processors, and is what the >> operator does when overflow checks are disabled, but numerically it's weird. Consider, instead, using Self::unbounded_shr which has nicer behaviour.
Note that this is not the same as a rotate...
method
core
Stable since 1.2.0
Version 1.100.0-nightly
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
docs.rs
...a bare byte-oriented x25519 function which matches the function specified in RFC7748 , as well as a higher-level Rust API for static and ephemeral Diffie-Hellman. Examples Alice and Bob are two adorable kittens who have lost their mittens, and they wish to be able to send secret messages...
Crate
v3.0.0
2026-07-06
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