brson.github.io
...util
canvas->azure
canvas->geom
canvas->cssparser
canvas->gleam
canvas->num
offscreen_gl_context
offscreen_gl_context
canvas->offscreen_gl_context
cssparser->encoding
matches
matches
cssparser->matches
gleam->libc
gl_common
gl_common
gleam->gl_common
gl_generator
gl_generator
gleam->gl_generator
khronos_api
khronos_api
gleam->khronos_api...
Notable Links
2015-05-18
~3 min read
blog.urth.org
...That’s because I’m using Rust’s
enum-based pattern matching. The Node enum has over 100 variants. That’s a lot of matching!I also need to generate enum wrappers around many structs. Any time a struct references another
struct, I need the wrapper indirection. So for example...
Observations/Thoughts
2021-03-17
~9 min read
blog.cloudflare.com
...right hand side is parsed and used as a byte sequence (will match a URL "/1234567")Are there other examples of such ambiguities? Yup - for example, we can try using a single number with two decimal digits:tcp.port == 80: matches any traffic on the port 80 (HTTP)http.file...
News & Blog Posts
2019-03-05
~17 min read
rust-lang.github.io
...Usually, you'll want to copy this value from a corresponding -fpatchable-function-entry= being passed to the C compiler in your project - total_nops will match the first parameter used by your C compiler, and the optional offset parameter passed to the C compiler will match prefix_nops.
To...
RFC 3543
RFC
2023-12-12
~11 min read
rust-lang.github.io
...Motivation
Right now accessing fields of tuples and tuple structs is incredibly painful—one must rely on pattern-matching alone to extract values. This became such a problem that twelve traits were created in the standard library (core::tuple::Tuple*) to make tuple value accesses easier, adding .valN(), .refN(), and...
RFC 184
RFC
2014-07-24
~1 min read
docs.babelmonkeys.de
...use xml::{Event, Parser}; // Create a new Parser let mut p = Parser::new(); // Feed data to be parsed p.feed_str("<a href"); p.feed_str("='//example.com'/>"); // Get events for the fed data for event in p { match event.unwrap() { Event::ElementStart(tag) => println!("<{}>", tag.name), Event::ElementEnd(tag...
Crate
v0.3.0
2020-03-08
ettolrach.com
...Expr::App(l, m) => match infer(*l, context)? {
Type::Arrow(a, b) => match check(*m.clone(), *a, context) {
Ok(_) => Ok(*b),
Err(TypeError {
kind:
ErrorKind::CheckedWrongType {
expected: a,
actual,
},
line,
column,
}) => Err(TypeError {
kind: ErrorKind::ArgWrongType {
expected: a,
actual,
},
line,
column,
}),
Err(e) => Err(e),
},
actual => Err(TypeError {
kind: ErrorKind...
Observations/Thoughts
2025-12-31
~15 min read
dev.to
...Option<&mut FdSet>) -> *mut libc::fd_set {
match opt {
None => ptr::null_mut(),
Some(&mut FdSet(ref mut raw_fd_set)) => raw_fd_set,
}
}
fn to_ptr<T>(opt: Option<&T>) -> *const T {
match opt {
None => ptr::null::<T>(),
Some(p) => p,
}
}
pub fn select(
nfds: libc::c_int,
readfds...
Rust Walkthroughs
2020-11-25
~12 min read
blog.sheerluck.dev
...LIKE and Pattern Matching#
LIKE does pattern matching on text. Two wildcards:
% matches any sequence of characters (including zero)
_ matches exactly one character
SELECT title FROM books WHERE title LIKE '%Rust%';
Output:
title
---------------------------
The Rust Programming Langua
%Rust% means “anything, then Rust, then anything.” It finds any title containing the...
Rust Walkthroughs
2026-07-01
~51 min read
ryangjchandler.co.uk
...fn compile_function(function: &Statement, source: &mut String) -> Result<(), CompileError> {
let (name, params, body) = match function {
Statement::Function { name, params, body, .. } => (name, params, body),
_ => unreachable!(),
};
source.push_str("fn ");
source.push_str(&name.name);
source.push('(');
for param in params {
source.push_str(match ¶m.name {
Expression::Variable(n) => &n...
Rust Walkthroughs
2022-08-24
~13 min read
docs.rs
...TomlError { message: "data did not match any variant of untagged enum Ohno", original: Some("\ninteger = 42\nstring = \"we want this to be spanned\"\n"), keys: ["string"], span: Some(23..51) } } } To understand why this fails we can look at what #[derive(serde::Deserialize)] expand to for Ohno in HIR. #[allow...
Crate
v0.7.2
2026-10-02
marketplace.visualstudio.com
...this session),
"numfiles": (number of rs files in workspace),
"result": {
"fns": (hashmap of relevant function data),
"loops": (location and depth of loops),
"matches": (location and depth of matches),
"let_exprs": (`if let` patterns),
"iter_mthds": (methods on iterators),
"calls": (function calls and contexts),
"unsafe_blocks": (location of unsafe blocks),
"no...
Project/Tooling Updates
2023-11-29
~3 min read
chrissardegna.com
...let maybe_event = match event_source.try_read(poll_timeout.leftover()) { ... }
This event sends a buffer to fill with data from a predefined file descriptor.
match self.tty_fd.read(&mut self.tty_buffer, TTY_BUFFER_SIZE) { ... }
In the self.tty_fd.read() call, crossterm invokes the read() syscall on...
Observations/Thoughts
2022-08-03
~8 min read
robinmoussu.gitlab.io
...The concrete type of all the branches of any conditional expression (like if, match, any kind of loop, …) must match.
Oh right. I wish that the compiler would be smart enough to create a newtype
automatically, but that’s not the case currently and the lang team is already
working...
Observations/Thoughts
2021-03-31
~7 min read
llogiq.github.io
...synstructure::Structure has many useful methods to construct or match over
values. The variants() method returns a slice of VariantInfo for all
variants (one for structs, any number for enums), which one can iterate to
generate code for each variants. There is also an .each(..) method to
generate matches.
To...
News & Blog Posts
2018-08-28
~1 min read
doc.rust-lang.org
pub enum Cow<'a, B>
...v }
}
}
// Creates a container from borrowed values of a slice
let readonly = [1, 2];
let borrowed = Items::new((&readonly[..]).into());
match borrowed {
Items { values: Cow::Borrowed(b) } => println!("borrowed {b:?}"),
_ => panic!("expect borrowed value"),
}
let mut clone_on_write = borrowed;
// Mutates the data from slice into owned vec and pushes...
enum
alloc
Stable since 1.0.0
Version 1.100.0-nightly
developerlife.com
...let mut terminal_async = match maybe_terminal_async {
None => return Ok(()),
_ => maybe_terminal_async.unwrap(),
};
// Initialize tracing w/ the "async stdout".
tracing_setup::init(TracingConfig::new(Some(
terminal_async.clone_shared_writer(),
)))?;
// Start tasks.
let mut interval_1_task = interval(Duration::from_secs(1));
let mut interval_2_task = interval...
Project/Tooling Updates
2024-04-24
~3 min read
crates.io
...Vec<OsString>) -> windows_service::Result<()> { let event_handler = move |control_event| -> ServiceControlHandlerResult { match control_event { ServiceControl::Stop | ServiceControl::Interrogate => { ServiceControlHandlerResult::NoError } _ => ServiceControlHandlerResult::NotImplemented, } }; // Register system service event handler let status_handle = service_control_handler::register("my_service_name", event_handler)?; let next_status = ServiceStatus { // Should match the one from system...
Crate
v0.8.1
2026-05-08
docs.rs
...Originally intended to be a way to just parse the semver spec into data structures, with no logic around matching and such, this functionality now lives in the semver crate, and therefore, is no longer used.
Crate
v0.10.3
2024-11-18
memo.barrucadu.co.uk
...impl RecordType {
pub fn matches(&self, qtype: &QueryType) -> bool {
match qtype {
QueryType::Wildcard => true,
QueryType::Record(rtype) => rtype == self,
}
}
}
#[derive(Debug, Copy, Clone)]
pub enum QueryClass {
Record(RecordClass),
Wildcard,
}
impl RecordClass {
pub fn matches(&self, qclass: &QueryClass) -> bool {
match qclass {
QueryClass::Wildcard => true,
QueryClass::Record(rclass) => rclass == self,
}
}
}
There are...
Rust Walkthroughs
2022-03-09
~21 min read