rust-analyzer.github.io
#8611 (first contribution) add support for boolean values to "Fill match arms".
#8658 (first contribution) check more carefully for cases when a rename can’t be done.
#8582 (first contribution) fix typo in comparison semantic token type.
#8600 fix project loading hang.
#8606 fix "Registering progress handler" error.
#8639 fix...
Project/Tooling Updates
2021-04-28
~1 min read
adventures.michaelfbryan.com
...f32) -> Point {
let raw = match self.units {
Units::Millimetres => Point::new::<millimeter>(x, y, z),
Units::Inches => Point::new::<inch>(x, y, z),
};
match self.coordinate_mode {
CoordinateMode::Absolute => raw,
CoordinateMode::Relative => raw + self.current_location,
}
}
fn calculate_feed_rate(&self, command: &GCode) -> Velocity {
let raw = match command.value_for...
News & Blog Posts
2019-11-12
~12 min read
github.com
...Vec<(&'static str, Value)>, encoder: &'a Encoder, ) -> FutureRecord<'a> { let subject_name_strategy = SubjectNameStrategy::TopicNameStrategy(topic, false); let payload = match encoder.encode(values, &subject_name_strategy) { Ok(v) => v, Err(e) => panic!("Error getting payload: {}", e), }; FutureRecord { topic, partition: None, payload: Some(&payload), key, timestamp: None, headers: None, } } fn get...
Crate
v6.0.0
2026-10-22
holovskyi.github.io
...client.subscribe("sensors/+/+/temperature", QoS::AtMostOnce).await?;
while let Ok(notification) = eventloop.poll().await {
match notification {
Event::Incoming(Packet::Publish(publish)) => {
let parts: Vec<&str> = publish.topic.split('/').collect();
if parts.len() == 4 && parts[0] == "sensors" && parts[3] == "temperature" {
let location = parts[1];
let sensor_id = parts[2];
match serde...
Project/Tooling Updates
2026-07-08
~4 min read
crates.io
...Catch-all variant Sometimes it is desirable to have an Other variant which holds the otherwise un-matched value as a field. The #[num_enum(catch_all)] attribute allows you to mark at most one variant for this purpose. The variant it's applied to must be a tuple variant...
Crate
v0.7.6
2026-03-15
noiseonthenet.space
...T ) {
match self.root{
None => {
self.root = Node::new(value).into();
}
Some(ref mut node) => {
Tree::<T>::insert_recursive(node, value);
}
}
}
fn insert_recursive(node : & mut Node<T>, value : T){
if value > node.value{
match node.right{
None => {
node.right = Node::new(value).into();
}
Some(ref mut n) => {
Tree::<T...
Observations/Thoughts
2024-04-17
~7 min read
dev.to
...Stripping unwanted trailing characters went from a slow regex match inside a loop:
// The old, slow regex way
pub(crate) fn trim_unwanted_end_chars<'a>(&self, phone_number: &'a str) -> &'a str {
// ... loop with regex.full_match() ...
}
Enter fullscreen mode
Exit fullscreen mode
To a single, native Rust iterator...
Project/Tooling Updates
2026-03-11
~7 min read
arzg.github.io
...u8) {
let mut lhs = match p.peek() {
// snip
};
loop {
let op = match p.peek() {
Some(SyntaxKind::Plus) => InfixOp::Add,
Some(SyntaxKind::Minus) => InfixOp::Sub,
Some(SyntaxKind::Star) => InfixOp::Mul,
Some(SyntaxKind::Slash) => InfixOp::Div,
_ => return, // we’ll handle errors later.
};
let (left_binding_power, right_binding_power) = op.binding_power...
Rust Walkthroughs
2020-12-16
~16 min read
doc.rust-lang.org
pub macro pin!
...let mut pinned_fut = pin!(fut);
loop {
match pinned_fut.as_mut().poll(&mut cx) {
Poll::Pending => thread::park(),
Poll::Ready(res) => return res,
}
}
}
With Coroutines
#![feature(coroutines)]
#![feature(coroutine_trait)]
use core::{
ops::{Coroutine, CoroutineState},
pin::pin,
};
fn coroutine_fn() -> impl Coroutine<Yield = usize, Return = ()> /* not Unpin */ {
// Allow coroutine...
macro
core
Stable since 1.68.0
Version 1.100.0-nightly
crates.io
...Catch-all variant Sometimes it is desirable to have an Other variant which holds the otherwise un-matched value as a field. The #[num_enum(catch_all)] attribute allows you to mark at most one variant for this purpose. The variant it's applied to must be a tuple variant...
Crate
v0.7.6
2026-03-15
svartalf.info
...io_object_t) -> kern_return_t;
}
unsafe {
let match_dict = IOServiceMatching(
b"IOPMPowerSource\0".as_ptr() as *const c_char
);
let mut iterator: io_iterator_t = mem::uninitialized();
// TODO: Handle the possible error
let _result = IOServiceGetMatchingServices(
master_port,
match_dict,
&mut iterator,
);
}
IOServiceMatching documentation says that the returned match_dict...
News & Blog Posts
2019-06-04
~7 min read
doma.dev
...Equivalently, one can't solve the matching parentheses problem with a regular expression. The simplest stack machine is needed for that.
Stack automaton can be in several states at once. A state with no transitions "fizzles" on any input. (@\* matches character '(' with any stack state. ε@ε matches instantaneously as...
Rust Walkthroughs
2021-03-31
~8 min read
boats.gitlab.io
...Match ergonomics
Match ergonomics have been stable for a while, but I continue to find them
paying dividends. I’m sure there are times where I’ve used it without even
noticing it, but there were many cases where I did notice. My experience
usually went like this:
I write...
News & Blog Posts
2018-07-31
~6 min read
rust.code-maven.com
...u32 = match args[1].parse() {
Ok(value) => value,
Err(err) => {
eprintln!("Invalid parameter: '{}'. It must be an integer", err);
eprintln!("Usage: {} INTEGER", &args[0]);
std::process::exit(1);
}
};
number
}
Here we have a match that is expected to return a 32-bit unsigned integer, a u32.
However, if the user...
Miscellaneous
2023-12-06
~3 min read
softprops.github.io
...Option<u64> } fn main() { match envy::from_env::<Config>() { Ok(config) => println!("{:#?}", config), Err(error) => panic!("{:#?}", error) } } ... export some environment variables $ FOO=8080 BAR=true BAZ=hello yourapp You should be able to access a completely typesafe config struct deserialized from env vars. Envy assumes an env var exists for...
Crate
v0.4.2
2021-01-04
kerkour.com
...Pattern matching in Rust can be used to match against many other expressions:
match x {
42 => println!("Good!"),
_ => println!("Bad!"),
}
let boolean = true;
// Match is an expression too
let binary = match boolean {
false => 0,
true => 1,
};
let x = Some(42u64);
match x {
Some(1) => println!("1"),
Some(42) => println!("42...
Rust Walkthroughs
2022-03-09
~9 min read
www.diegofreijo.com
...pub fn scan_token(&mut self) -> TokenResult<'a> {
self.skip_whitespaces();
self.start = self.current;
match self.advance() {
Some(c) => match c {
_ if Scanner::is_alpha(c) => self.identifier(),
_ if Scanner::is_digit(c) => self.number(),
// Single-char tokens
'(' => self.make_token(TokenType::LeftParen),
')' => self.make_token(TokenType::RightParen),
// (...)
'<' => self...
Rust Walkthroughs
2022-02-09
~13 min read
crates.io
...a test my_test that accepts a path, and optionally the contents as input a directory to look for files (test fixtures) in a pattern to match files on datatest-stable will call the my_test function once per matching file in the directory. Directory traversals are recursive. datatest-stable...
Crate
v0.3.3
2026-03-31
blog.burntsushi.net
...Match
In this case, Split means “jump to two different instructions
simultaneously.” In particular, if either branch executes the Match
instruction, then the entire regex will match. If both Char instructions
fail, then it’s impossible to reach the Match instruction.
Clarifying the divide: native regexes vs. dynamic regexes
The...
Community Updates
2014-05-05
~18 min read
smallcultfollowing.com
...it starts as we enter the match
(match &message) and continues into the match arm. On the else
branch of the match, the borrow is still in use (in the form of the
data variable), but in the if branch, it is not (and hence we can
call tx.send...
News & Blog Posts
2018-11-06
~5 min read