johns.codes
...let mut exec = sql_jr_execution::Execution::new();
loop {
let readline = rl.readline(">> ");
match readline {
Ok(line) => {
rl.add_history_entry(line.as_str());
let line: &str = line.as_ref();
let res = exec.parse_and_run(line);
match res {
Ok(exec_res) => println!("{exec_res}"),
Err(e) => {
let mut s...
Rust Walkthroughs
2023-01-25
~11 min read
metalbear.co
...Our handler will be called using the C ABI calling convention, it will match on syscalls and redirect them based on their type to their specific detours and return the result in the specific register conforming to the C ABI.#[no_mangle]
unsafe extern "C" fn c_abi_syscall_handler...
Rust Walkthroughs
2022-08-17
~11 min read
siciarz.net
...std::io::Read
{
match *x
{
Some(_) => {Ok(y)},
None => Err("not happening".into())
}
}
into this:
fn make_it_happen<T, U>(x: &Option<T>, y: U) -> Result<U, String>
where T: std::io::Write,
U: std::io::Read
{
match *x {
Some(_) => Ok(y),
None => Err("not happening".into()),
}
}
rustfmt fixed...
News & Blog Posts
2016-12-06
~5 min read
developerlife.com
...syn::Type =
syn::parse_str::<syn::Type>(&traits.join(" + ")).unwrap();
let where_clause_ts = match where_clause {
Some(where_clause) => {
let where_predicate_punctuated_list = &where_clause.predicates;
let modified_where_predicates_ts = where_predicate_punctuated_list
.iter()
.map(
|where_predicate| match where_predicate {
syn::WherePredicate::Type(_) => {
quote! { #where_predicate...
Rust Walkthroughs
2023-04-26
~35 min read
tmandry.gitlab.io
...let xs = vec![1, 2, 3];
let mut gen = move || {
let mut sum = 0;
{
let mut iter0 = xs.iter();
loop {
match iter0.next() {
Some(x0) => {
sum += x0;
yield sum; // Suspend0
}
None => break,
}
}
}
{
let mut iter1 = xs.iter().rev();
loop {
match iter1.next() {
Some(x1) => {
sum -= x1;
yield sum; // Suspend1
}
None...
News & Blog Posts
2019-09-10
~16 min read
chunkofcoal.com
...But the low nibble 0xC only matches COMMA. The AND eliminates QUOTE, leaving just COMMA.Building these lookup tables requires some care. Because the AND combines results from 2 independent lookups, you’re effectively designing a grid. Any byte whose high nibble matches and whose low nibble matches will be...
Rust Walkthroughs
2026-03-25
~11 min read
doc.rust-lang.org
...iterator, returns an (Optional) String
for line in lines.map_while(Result::ok) {
println!("{}", line);
}
}
}
// The output is wrapped in a Result to allow matching on errors.
// Returns an Iterator to the Reader of the lines of the file.
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io...
Rust by Example
Book
2024-01-01
~1 min read
iohk.io
...our team, learn more about our projects, and get a real sense of our culture and ways of working.Offer03If it’s a good match, we'll move to offer, complete a background check, and prepare to welcome you through onboarding.From day one, we want you to feel informed...
Rust Jobs
2020-10-07
~1 min read
cat-solstice.github.io
...That’s wild!
replace the hint::select_unpredictable with the worst match statement possible:
match f( unsafe { slice.get_unchecked(mid) } ) {
Ordering::Less | Ordering::Equal => base = mid,
Ordering::Greater => {},
}
The performance of all tested cases are now similar to each other (and good) but there is no more conditional moves...
Observations/Thoughts
2025-10-29
~11 min read
blog.yoshuawuyts.com
...The
version I’ve seen which I like the most used type ascription when matching, but
that’s hard to implement, and has a bunch of other lang implications as well:
match foo(cond) {
n: u32 => {},
n: u16 => {}
}
Though if someone has ideas how to prototype this, it would be...
Observations/Thoughts
2022-02-16
~11 min read
rust-lang-nursery.github.io
...Option<String>,
},
}
fn main() {
let args = NotesArgs::parse();
if args.color {
println!("Enabled syntax highlighting");
}
match args.command {
Commands::New { title, body } => {
// Prints:
// TITLE: ...
// BODY: ...
println!(
"Creating new note!\nTITLE: {}\n{}",
title,
if let Some(body) = body {
format!("BODY: {}", body)
} else {
"".into()
}
);
}
Commands::List => println!("Listing available tasks"),
Commands::Delete...
The Rust Cookbook
Book
2024-01-01
~2 min read
boats.gitlab.io
...Today, it expands something like this:
// This
await!(future)
// Expands like this
loop {
match future.poll() {
Ok(Async::NotReady) => yield,
Ok(Async::Ready(data)) => Ok(data),
Err(error) => Err(error),
}
}
Importantly, once you await a future, you can’t do anything with it again.
This gives us the leeway to...
News & Blog Posts
2018-02-13
~5 min read
security.googleblog.com
...match process_response(unsafe {
slice::from_raw_parts(dns_response, response_len)
}) {
Ok(()) => 0,
Err(err) => err.into(),
}
}
fn process_response(response: &[u8]) -> Result<()> {
let response = hickory_proto::op::Message::from_bytes(response)?;
let response = hickory_proto::xfer::DnsResponse::from_message(response)?;
for answer in response.answers() {
match answer.record...
Rust Walkthroughs
2026-04-15
~8 min read
news.ycombinator.com
Hadean | Systems Programmer | London | ONSITE, VISAWe're looking for a brilliant systems-level implementor to join us in London, or potentially remote, who matches ≥6 of the following: • loves C
• loves Rust
• has a wide array of ambitious self-directed projects
• has got their hands dirty writing technically complex systems...
fn work(on: RustProject) -> Money
2017-01-10
~1 min read
seanmonstar.com
...back out:
match req.headers.get() {
Some(&ContentType(Mime(Application, Json, _))) => "it's json!",
Some(&ContentType(Mime(top, sub, _))) => "we can handle top and sub",
None => "le sad"
}
Here’s an example that makes sure the format is correct:
req.headers.set(Date(time::utc_now()));
// ...
match req.headers.get...
Blog Posts
2014-12-22
~5 min read
adventures.michaelfbryan.com
...We just need to handle the on_key_pressed() event and match
on the key that was pressed, returning a Transition::ChangeState if it’s
a button we support.
// demo/src/modes/idle.rs
impl State for Idle {
fn on_key_pressed(
&mut self,
_drawing: &mut dyn Drawing,
event_args...
News & Blog Posts
2020-02-11
~41 min read
blog.eldruin.com
...It seems the measurements match the humidity, rather than the CO2 concentration. I made other measurements with an iAQ-Core-C sensor I got from MOUSER and these did resemble what one would expect. I will publish those here soon.Possibly my CCS811 is simply worn off. If you are...
Project Updates
2020-09-16
~4 min read
blog.servo.org
...One of our contributors, Florian Duraffourg, landed a patch recently that switched our public domain list matching source and algorithm, resulting in a huge speedup in page load times (~25%!). Shing Lyu tracked down and measured this unexpectedly-large gain through a new automated page load testing performance infrastructure that...
New Crates & Project Updates
2016-06-27
~1 min read
smallcultfollowing.com
...To a human, this is clearly an ImportDecl;
in particular, it matches this production:ImportDecl = "import" Path "." "*" ";"
But to the computer, this is not a match at all. The second thing
listed after "import" should be a path not an identifier. Now of
course there is a rule that lets...
News & Blog Posts
2016-03-07
~12 min read
www.capturedlambda.dev
...Vec<Item> = Vec::new();
customer.fetch_shopping_list(&mut items);
for item in items.iter_mut() {
match store.fetch_item(item) {
Response::Available => {
mark_as_available(&mut item);
continue;
}
Response::NotAvailable => continue;
// this early return is why we are
// splitting looking up the items
// and actually loading them into
// the...
Observations/Thoughts
2025-04-23
~19 min read