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
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
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
crates.io
...This means that you cannot directly match on an IValue to determine its type. Instead, an IValue offers several ways to get at the inner type: Destructuring using IValue::destructure[{_ref,_mut}]() These methods return wrapper enums which you can directly match on, so these methods are the most direct...
Crate
v0.1.7
2026-07-16
docs.rs
...std::fs::{symlink_file, symlink_dir} , matching symlink_auto or nothing. std::fs::{soft_link_file, soft_link_dir} , matching soft_link if it is undeprecated. But I don’t like the name “soft link,” anyway: no one calls them that, we all call them symlinks. Note that despite the...
Crate
v0.1.0
2017-01-27
magiclen.org
...In this crate, crc32 matches crc32b from mhash , and crc32mhash matches crc32 from mhash . crc32bzip2 crc32c crc32d crc32mpeg2 crc32posix crc32q crc32jamcrc crc32xfer crc40gsm crc64 crc64iso crc64we crc64jones For example: use crc_any::CRC; let mut crc64 = CRC::crc64(); crc64.update(b"hello"); After you get a CRC value, you can...
Crate
v3.0.1
2026-06-28
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-lang-nursery.github.io
...badge]][cat-text-processing] | | Extract phone numbers from text | [![regex-badge]][regex] | [![cat-text-processing-badge]][cat-text-processing] | | Filter a log file by matching multiple regular expressions | [![regex-badge]][regex] | [![cat-text-processing-badge]][cat-text-processing] | Replace all occurrences of one text pattern with another pattern. | [![regex-badge...
The Rust Cookbook
Book
2024-01-01
~1 min read
docs.rs
...extern crate unicode_normalization_alignments; use unicode_normalization_alignments::char::compose; use unicode_normalization_alignments::UnicodeNormalization; fn main() { assert_eq!(compose('A','\u{30a}'), Some('Å')); let s = "ÅΩ"; let c = s.nfc().map(|(c, diff)| { match diff { 0 => println!("Nothing changed here"), 1 => println!("New character"), _ => println!("{} characters were...
Crate
v0.1.12
2019-12-30
crates.io
...Currently a lot of documentation is rather terse, referring to the matching methods on the string types in the standard library is best in those cases. Feel free to contribute more exhaustive in-line docs.
Crate
v0.2.0
2020-10-10
1:10:53
Rustacean Station
rustacean-station.org
Episode: What's New in Rust 1.42 and 1.43
...And then the second argument is a pattern similar to what you
would write in any like match arm. And it just evaluates to true if the given expression matches
that pattern and to false otherwise. So it really just de-sugars to a match or like match of the...
Podcast
2020-05-08
1:10:53
guillaumegomez.github.io
...and added ‘platform-specific’ section to sleep_ms to match sleep..
@jmdyck added a link to the second edition of The Book.
@steveklabnik fixed wording around sort guarantees.
@estebank taught diagnostics to highlight text and provided disambiguated syntax for candidates in E0034.
@APTy added docs and tests for join_multicast...
Other Weeklies from Rust Community
2017-01-17
~2 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
docs.rs
...Example match rexif::parse_file(&file_name) { Ok(exif) => { println!("{} {} exif entries: {}", file_name, exif.mime, exif.entries.len()); for entry in &exif.entries { println!(" {}: {}", entry.tag, entry.value_more_readable); } }, Err(e) => { eprintln!("Error in {}: {} {}", &file_name, Error::description(&e), e.extra).unwrap(); } } The src/main.rs file is...
Crate
v0.7.5
2024-12-02
mobiarch.wordpress.com
...fn make_dir(path: &str) -> std::io::Result<()> {
let err = match std::fs::create_dir(path) {
Ok(_) => return Ok(()),
Err(e) => e
};
match err.kind() {
ErrorKind::AlreadyExists => return Ok(()),
_ => {
println!("Failed to create directory: {}", path);
return Err(err);
}
};
}
getenv
Use std::env:var.
if let Ok(val) = std::env::var...
From the Blogosphere
2015-07-13
~2 min read
arXiv
arxiv.org
...This work investigates aforementioned features, in particular pattern matching, providing a consistent view on how to apply MC/DC to Rust. Hence, this paper informs the implementation of Rust MC/DC tools, paving the road towards Rust in high-assurance applications.
Software Engineering
Wanja Zaeske, Pietro Albini, Florian Gilcher et al.
2024-09-13
arXiv:2409.08708
www.redox-os.org
...The public key must match the
one installed on disk. The signature of the struct must verify against the
public key. If this is true, the hash and entry count are considered valid.
The entry metadata can now be downloaded to a temporary file. During the
download, the BLAKE3 hash...
News & Blog Posts
2020-03-17
~5 min read
ryhl.io
...In the example above, we match on the enum inside a handle_message method on
the actor struct, but that isn't the only way to structure this. One could also
match on the enum in the run_my_actor function. Each branch in this match
could then call various...
Rust Walkthroughs
2021-02-17
~11 min read