docs.rs
...enum Fruit { Apple, Bramble(BrambleFruit), Pear, } trait NameOf { fn name_of(&self) -> &str; } impl NameOf for Fruit { fn name_of(&self) -> &str { match self { Fruit::Apple => "apple", Fruit::Bramble(fruit) => fruit.name_of(), Fruit::Pear => "pear", } } } enum BrambleFruit { Blackberry, } impl NameOf for BrambleFruit { fn name_of(&self) -> &str { match self...
Crate
v2.1.0
2025-11-07
blog.logrocket.com
...Wiremock mocks HTTP responses using request matching and response templating techniques. Request matching checks if the incoming request meets specified conditions. You specify these conditions in the handler. Response templating helps to generate the content of the API response.
Here’s an example of mocking with Wiremock:
#[cfg(test)]
mod...
Rust Walkthroughs
2023-05-24
~16 min read
docs.rs
...foundationdb::Database::default()?; // write a value in a retryable closure match db .run(|trx, _maybe_committed| async move { trx.set(b"hello", b"world"); Ok(()) }) .await { Ok(_) => println!("transaction committed"), Err(_) => eprintln!("cannot commit transaction"), }; // read a value match db .run(|trx, _maybe_committed| async move { Ok(trx.get(b...
Crate
v0.11.0
2026-06-24
rustc-dev-guide.rust-lang.org
...match arms were matching in the wrong order".
These comments are very useful to others later on when your test breaks, since they often can highlight what the problem is. They are also useful if for some reason the tests need to be refactored, since they let others know which...
Guide to Rustc Development
Book
2024-01-01
~6 min read
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.
Comments:
19 pages, 1 figure, 9 listings
Subjects:
Software...
Research
2024-09-18
~1 min read
doc.rust-lang.org
pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)>
...Examples
use std::net::TcpListener;
let listener = TcpListener::bind("127.0.0.1:8080").unwrap();
match listener.accept() {
Ok((_socket, addr)) => println!("new client: {addr:?}"),
Err(e) => println!("couldn't get client: {e:?}"),
}
method
std
Stable since 1.0.0
Version 1.100.0-nightly
udoprog.github.io
...I hope this makes it apparent why a byte-order naive application can’t process
archives correctly unless the byte order used in the archive matches the native
byte order. In order to interpret the values correctly we somehow need extra
information and careful processing.
The dictionary I built this...
Observations/Thoughts
2023-11-01
~13 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
v0.95.2
2026-08-06
llogiq.github.io
...The point is that the match follows some simple
rules, and we can embed stuff from the match in the expression.
We take a list of comma separated expressions (spaces don’t count), and take
the first and the rest separately; the $(..),* in the match means zero or
more comma...
News & Blog Posts
2016-05-02
~13 min read
docs.rs
...Basic selector matching (including child and descendents, classes and element types). Attribute selectors including [foo] and [foo="bar"] nth-child pseudo-class. CSS colors ( color / background-color ) will add Coloured(...) / BgColoured(...) nodes to the render tree. Rules with display: none will cause matching elements to be removed from the render...
Crate
v0.17.1
2026-04-19
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
andreaskroepelin.de
...PlayerClass
}
impl PlayerClass {
fn homestar(&self) -> String {
use PlayerClass::*;
match self {
Sol(_) => String::from("sun"),
...
}
}
fn greet(&self, other: &PlayerClass) {
use PlayerClass::*;
match (self, other) {
(Cent(_), Pol(_)) => println!("Hello, fellow three-star-systemer!"),
...
};
}
}
This indeed solves all our previous problems and is hence the go-to pattern for this situation...
Observations/Thoughts
2020-09-04
~6 min read
rocket.rs
...The attribute describes the requests that match the route. The attribute is placed on top of a function that is the request handler for that route. As an example, consider the simple route below: 1
2
3
4#[get("/")]
fn index() -> &'static str {
"Hello, world!"
}
This index route matches any...
Crate of the Week
2023-11-22
~6 min read
www.mattkennedy.io
...Enum methods require an implementation for each of the variants, which is done using pattern matching.
enum Shape {
Rectangle { width: f64, height: f64 },
Circle { radius: f64 },
RightAngleTriangle { base: f64, height: f64 },
}
impl Shape {
fn area(&self) -> f64 {
match self {
Shape::Rectangle { width, height } =>
width * height,
Shape::Circle { radius } =>
std::f64...
Observations/Thoughts
2020-12-16
~6 min read
blog.dureuill.net
...HashMap<Input, RequestStatus>,
}
impl Parser {
pub fn new() -> Self {
let (command_sender, command_receiver) = channel::<Command>();
let (response_sender, response_receiver) = channel::<(Input, Response)>();
std::thread::spawn(move || loop {
match command_receiver.recv() {
Ok(Command::Input(input)) => {
let response = parse(input);
let _ = response_sender.send((input, response));
}
Ok(Command::Exit...
Observations/Thoughts
2024-02-14
~6 min read
www.ralfj.de
...A Uniq item matches a Uniq tag with the same ID.
A Shr item matches any Shr tag (with or without timestamp).
When we are reading, a Shr item matches a Uniq tag.
If we pop the entire stack without finding a match, then we have undefined
behavior.
To understand...
News & Blog Posts
2018-11-20
~36 min read
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
zellij.dev
...BTreeSet<{KeyModifier::Ctrl, KeyModifier::Shift}>
}
RustThe KeyWithModifier struct provides us with useful methods so that we can match against it in a readable way. Let’s look at our update function now:impl ZellijPlugin for State {
// ...
fn update(&mut self, event: Event) -> bool {
let mut should_render = false;
match event...
Rust Walkthroughs
2024-12-04
~22 min read