getcode.substack.com
...Since they operate element-wise, their shapes must match.In functional programming terms, these operations are like map2 or zip: they apply a binary function elementwise to two tensors.I said the input tensors' shape must match, but I didn't explain what that means. Trivially, two shapes match if...
Rust Walkthroughs
2023-05-03
~39 min read
dev.to
...In Rust, it's nice that I can make enums be so useful, and moreover, the compiler will throw errors if I have enum values that are never used in match statements. Compare that to Go where missing type values in a switch statement will not throw any kind of...
Observations/Thoughts
2021-01-27
~13 min read
www.snoyman.com
...mut set = tokio::task::JoinSet::new();
for url in urls {
set.spawn(download_and_print(&url));
}
while let Some(result) = set.join_next().await {
match result {
Ok(Ok(())) => (),
Ok(Err(e)) => {
set.abort_all();
return Err(e);
}
Err(e) => {
set.abort_all();
return Err(e.into());
}
}
}
Ok(())
}
While the parallelism...
Observations/Thoughts
2023-09-13
~5 min read
blog.0xshadow.dev
...If they match exactly, it proves two things: first, that the token was indeed created by someone who knows the secret key (which should only be the server), and second, that the header and payload haven’t been modified since the token was created.
If the signatures match, the server...
Rust Walkthroughs
2025-10-01
~34 min read
www.meilisearch.com
...A search for 2024 will match only 2024, not 2025 or 2004. This is especially helpful when searching for postal addresses or phone numbers.
Skipping number fuzziness can also speed up your indexing, especially for datasets that contain many unique numbers.
New: Lexicographic string filters
You can now compare any...
Project/Tooling Updates
2025-06-11
~2 min read
dfockler.github.io
...Previous code here
match input_line.trim() {
"exit" => break,
line => {
// !!!!!! Here we changed parse_Num to parse_Expr to match our
// grammar code
println!("{:?}", smellyalater::parse_Expr(&line.to_string()));
}
}
// ... More code under here
Finally we can see what our final src/smellyalater.lalrpop file looks like.
// use std::str...
News & Blog Posts
2016-09-20
~13 min read
www.possiblerust.com
...Refutability
One restriction of pattern matching in function signatures is that you can only use
irrefutable patterns, meaning patterns that always match.
By contrast, refutable patterns may sometimes fail to match,
perhaps because they specify only a single variant of an enum with multiple variants.
Refutable patterns can be used...
Rust Walkthroughs
2021-02-03
~21 min read
dev.to
...We then pass the index associated with the found entry to our touch_index method, which handles moving the entry to the head of the list:
/// Touches the first entry in the cache that matches the
/// given predicate. Returns `true` on a hit and `false`
/// if no match is found...
Rust Walkthroughs
2021-01-27
~24 min read
blog.servo.org
...Manishearth updated rust-url to match new specification changes.
frewsxcv made placeholders appear in text areas.
SimonSapin replaced some uses of strings for CSS property names with enums.
UK992 fixed some issues with the Windows installer.
mmatyas made a number of improvements to allow Android to build again.
gw & frewsxcv...
Other Weeklies from Rust Community
2016-12-20
~2 min read
beachape.com
...SavedUser = labelled_convert_from(n_user);
but the following fails at compile-time because the fields are mis-matched (first_name and last_name have been swapped):
1
2
3
4
5
6
7
8
9
10
11
// Uh-oh! Fields are jumbled :(
#[derive(LabelledGeneric)]
struct JumbledUser<'a> {
last_name...
News & Blog Posts
2017-03-07
~9 min read
nitschinger.at
...1
2
3
4
5
6
7
8
9
10
println!("Cpu Binding before explicit bind: {:?}", topo.get_cpubind(CPUBIND_PROCESS));
println!("Cpu Location before explicit bind: {:?}", topo.get_cpu_location(CPUBIND_PROCESS));
match topo.set_cpubind(cpuset, CPUBIND_PROCESS) {
Ok(_) => println!("Correctly bound to last core"),
Err(e) => println...
News & Blog Posts
2016-02-15
~12 min read
www.heise.de
...u64 = 1024;
let response_content_length = match response.body().size_hint().upper() {
Some(v) => v,
None => MAX_ALLOWED_RESPONSE_SIZE + 1 // Just to protect ourselves from a malicious response
};
if response_content_length < MAX_ALLOWED_RESPONSE_SIZE {
let body_bytes = hyper::body::to_bytes(response.into_body()).await?;
println!("body...
Miscellaneous
2023-01-18
~2 min read
fasterthanli.me
...Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
println!("MyFuture::poll()");
match self.slept {
false => {
// make sure we're polled again in one second
let waker = cx.waker().clone();
std::thread::spawn(move || {
std::thread::sleep(Duration::from_secs(1));
waker.wake();
});
self.slept = true;
Poll::Pending
}
true => Poll...
Rust Walkthroughs
2021-03-31
~42 min read
blog.servo.org
...Applicants form pairs
(“teams”) and apply to be matched with a mentoring open source project - if a team is selected for a project, they will
contribute to that project for those three months while receiving a stipend and regular coaching in return.
How is this program different from similar Summer...
Call for Participation
2017-02-28
~2 min read
www.ralfj.de
...Whenever a mutable reference is created, a matching Uniq is pushed onto the stack for every location “covered by” the reference – i.e., the locations that would be accessed when the reference is used (starting at where it points to, and going on for size_of_val many bytes).
Whenever...
News & Blog Posts
2018-08-07
~25 min read
0xc45.com
...f32 = 0.2;
let period = note.envelope.clock / audio_ctx.sample_rate;
// determine next sample value
let sample = match note.waveform {
Waveform::SINE => (note.frequency * TAU * period).sin(),
Waveform::SQUARE => match (note.frequency * TAU * period).sin() {
i if i > 0_f32 => 1_f32,
_ => -1_f32,
},
Waveform::TRIANGLE => (note.frequency * TAU...
Observations/Thoughts
2022-01-19
~6 min read
osblog.stephenmarz.com
...8 => {
// Environment (system) call from User mode
println!("E-call from User mode! CPU#{} -> 0x{:08x}", hart, epc);
return_pc = do_syscall(return_pc, frame);
},
Most operating systems build a table with function pointers, but I'm using Rust's match statement here. I haven't done any performance calculations...
News & Blog Posts
2020-07-08
~6 min read
developerlife.com
...fn main() {
println!("Welcome to rtelnet");
let cli_arg = CLIArg::parse();
let address = cli_arg.address;
let port = cli_arg.port;
let socket_address = format!("{}:{}", address, port);
if !cli_arg.log_disable {
femme::start()
}
match match cli_arg.subcommand {
CLISubcommand::Server => start_server(socket_address),
CLISubcommand::Client => start_client(socket...
Rust Walkthroughs
2024-02-07
~13 min read
guillaumegomez.github.io
...Recent doc contributions
@estebank provided context for missing comma in match arm and if statement without block.
@vi added foldable impl blocks in rustdoc.
@QuietMisdreavus added readme for librustdoc.
@remexre fixed docs for ASCII functions to no longer claim U+0021 is ‘@’.
@mark-i-m splitted E0404 to E0909; get...
News & Blog Posts
2018-03-06
~2 min read
agmprojects.com
...DateTime<Utc>,
}
An important thing to note, the fields here in the struct need to match the order they are defined in the schema.rs file. This will also match the order they were defined in the migration file. So if you were to remove body and add it back...
Rust Walkthroughs
2021-05-12
~43 min read