blog.categulario.tk
...Enums y pattern matching. Aunque en el punto anterior mencioné los tipos unión este punto me parece tan importante que necesita su propio inciso. Es muy común cuando escribes código que estás ante la necesidad de representar información que viene en una de varias formas posibles. Hay formas muy tristes...
Observations/Thoughts
2020-08-11
~6 min read
blog.servo.org
...mrobinson corrected the behaviour of the scrollBy API to better match the specification.
jdm removed incorrect buffer padding in ipc-channel on macOS.
kvark fixed an assertion failure when rendering fonts on unix.
aneeshusa implemented per-repository labelling actions in highfive.
nox refactored the implementation of CSS position values to...
News & Blog Posts
2017-05-16
~1 min read
salvo.rs
...Browsers send preflight OPTIONS requests before the real request, and those preflight requests may not match any router branch. use salvo::cors::Cors; use salvo::http::Method; use salvo::prelude::*; #[handler] async fn hello() -> &'static str { "Hello World" } #[tokio::main] async fn main() { let cors = Cors::new() .allow_origin("https...
Crate
v1.2.1
2026-11-17
dev.to
...Your First Service
Next, let's open up the service.toml file for todo-service.
[service]
name = "my-service"
[api]
name = "my-service-api"
[api.functions.my-function]
name = "my-function"
handler_name = "handler"
Enter fullscreen mode
Exit fullscreen mode
Start by editing the names to match the ones we...
Learn Rust
2020-10-28
~11 min read
jam1.re
...fn return_trait_object() -> Box<Any + Send + Sync> {
todo!()
}
And since this still parses in spite of being deprecated, that means we can use it for our own nefarious macro purposes! (until it is inevitably removed)
The Pattern Matching
Unlike the function itself, matching on the anonymous sum type requires...
Observations/Thoughts
2020-11-18
~9 min read
docs.rs
Find peaks that match criteria in 1D data. Description Find a filtered subset of local maxima in 1D slice of data. The functionality implemented here is might be familiar to anyone using MATLAB's findpeaks , or Python's scipy.signal.find_peaks . Arguably, the most useful feature in this package...
Crate
v0.1.5
2022-05-18
arXiv
arxiv.org
...The Rust version matches the C implementation on all functionality tests, and produces identical outputs for the real-world PHP applications we evaluate. To our knowledge, this is the first principled safe Rust port of a core fragment of the PHP interpreter that combines formal guarantees of logical memory safety...
Cryptography and Security
Tianyu Li, Bo Wang, Prateek Saxena et al.
2026-11-24
arXiv:2611.32477
dev.to
...Second, I very much wrote this only for myself, so there isn't much in the way of robustness and error handling is only match statements and some if checks. I think that is something worth fixing.
Third and lastly, I really enjoyed traveling the internet under my own power...
Rust Walkthroughs
2020-11-04
~11 min read
blog.turbo.fish
...let meta = attr.parse_meta()?;
// Pattern matching and error handling…
}
When parsing into our own type, we can avoid all of the pattern matching and
even get some pretty good error handling "for free", but depending on the syntax
you want to parse, the parsing code can take a little...
Rust Walkthroughs
2021-12-29
~11 min read
xd009642.github.io
...while !pending_exprs.is_empty() {
assert!(tries_left > 0);
if index >= pending_exprs.len() {
index = 0;
tries_left -= 1;
}
let (expr_index, expr) = pending_exprs[index];
let lhs = region_ids.get(&expr.lhs);
let rhs = region_ids.get(&expr.rhs);
match (lhs, rhs) {
(Some(lhs), Some(rhs)) => {
pending_exprs.remove...
Observations/Thoughts
2025-05-14
~11 min read
rust-lang.github.io
...i32 = 3.pow(3);
match x {
CUBE => println!("three cubed"),
_ => {}
}
}
If that const is only used inside a single pattern, writing the code using an inline const block makes it easier to scan.
fn foo(x: i32) {
match x {
const { 3.pow(3) } => println!("three cubed"),
_ => {}
}
}
Reference-level explanation
This...
RFC 2920
RFC
2020-04-30
~7 min read
www.propelauth.com
...I find myself missing match in pretty much every other language I go to.However, if I was doing it over, I wouldn’t choose Rust.This advice is primarily for early startups (pre-product/pre-seed/seed). But first, it’s important to ask why we went with Rust...
Observations/Thoughts
2023-02-22
~3 min read
doc.rust-lang.org
The ref pattern
When doing pattern matching or destructuring via the let binding, the ref keyword can be used to take references to the fields of a struct/tuple. The example below shows a few instances where this can be useful:
#[derive(Clone, Copy)]
struct Point { x: i32, y: i32...
Rust by Example
Book
2024-01-01
~1 min read
julienblanchard.com
...extern crate regex;
use regex::Regex;
use std::env;
fn main() {
println!("Starting email-checker...");
let re = Regex::new(r"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$").unwrap();
match env::args().nth(1) {
Some(email) => {
if re.is_match(&email) {
println!("{} is a valid email.", email);
} else {
println!("{} is NOT a...
News & Blog Posts
2015-11-23
~3 min read
mtak-blog.github.io
...The write lock is no longer held and the version number matches the sequence number read at 1. The read is successful.
Other cases where a write lock is aquired after the read has acquired a sequence number are no different than a regular seqlock.
Now for a handwaving explanation...
News & Blog Posts
2019-03-26
~14 min read
diziet.dreamwidth.org
...macro_rules!’s pattern language doesn’t have a cooked way to match a data structure, so you have to hand-write a matcher for Rust syntax, in each macro. Writing such a matcher is very hard in the general case, because macro_rules lacks features for matching important parts...
Project/Tooling Updates
2025-02-19
~6 min read
seanchen1991.github.io
...For example, given the following student implementation of an Exercism exercise called two-fer
fn twofer(name: &str) -> String {
match name {
"" => "One for you, one for me.".to_string(),
// use the `format!` macro to return a formatted String
_ => format!("One for {}, one for me.", name),
}
}
would be transformed into the...
Learn More Rust
2020-08-04
~8 min read
docs.rs
...Example use rustyline::error::ReadlineError; use rustyline::{DefaultEditor, Result}; fn main() -> Result<()> { // `()` can be used when no completer is required let mut rl = DefaultEditor::new()?; #[cfg(feature = "with-file-history")] if rl.load_history("history.txt").is_err() { println!("No previous history."); } loop { let readline = rl.readline(">> "); match readline { Ok...
Crate
v19.0.0
2026-10-17
redox-os.org
...Currently, it attempts to match the Arc theme as closely as possible. The goal is to have all of the
changes required contained where it is easy for other themes to override them.
The login screen has been completely overhauled, as well as the title bars and OrbTK color scheme...
Other Weeklies from Rust Community
2017-02-28
~1 min read