sdleffler.github.io
...Smallfuck programs are strings of five instructions:
< | Pointer decrement
> | Pointer increment
* | Flip current bit
[ | If current bit is 0, jump past the matching ]; else, go to the next instruction
] | Jump back to the matching [ instruction
This gives you the ability to select cells and make loops. Here’s a simple...
News & Blog Posts
2017-03-14
~30 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
docs.rs
...Principle of Operation In general chardetng prefers to do negative matching (rule out possibilities from the set of plausible encodings) than to do positive matching. Since negative matching is insufficient, there is positive matching, too. Except for ISO-2022-JP, pairs of ASCII bytes never contribute to the detection, which...
Crate
v1.0.0
2026-03-30
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
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
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
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
www.fluvio.io
...If version is dev, Kubernetes will expect an image in its local registry with a name matching the pattern infinyon/fluvio-connect-<your connector name>:latest.
Otherwise, the value of version will refer to the image tag to pull from Docker Hub.
e.g.
infinyon/fluvio-connect-<your connector name...
Project/Tooling Updates
2022-02-09
~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
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
doc.rust-lang.org
...u8) -> bool {
matches!(n, 0...100) // should be `0..=100`
}
Migrations
If your Rust 2015 or 2018 code does not produce any warnings for bare_trait_objects or ellipsis_inclusive_range_patterns and you've not allowed these lints through the use of #![allow()] or some other mechanism, then there...
The Rust Edition Guide
Book
2024-01-01
~1 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
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
v18.0.1
2026-06-24
doc.rust-lang.org
pub fn char_indices(&self) -> CharIndices<'_>
...Some((5, 'y')), char_indices.next());
assert_eq!(Some((6, 'e')), char_indices.next());
assert_eq!(None, char_indices.next());
Remember, chars might not match your intuition about characters:
let yes = "y̆es";
let mut char_indices = yes.char_indices();
assert_eq!(Some((0, 'y')), char_indices.next()); // not (0, 'y̆...
method
core
Stable since 1.0.0
Version 1.100.0-nightly
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
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
doc.rust-lang.org
pub fn try_send(&self, t: T) -> Result<(), TrySendError<T>>
...msg;
msg = receiver.recv().unwrap();
println!("message {msg} received");
msg = receiver.recv().unwrap();
println!("message {msg} received");
// Third message may have never been sent
match receiver.try_recv() {
Ok(msg) => println!("message {msg} received"),
Err(_) => println!("the third message was never sent"),
}
// Wait for threads to complete
handle1.join().unwrap...
method
std
Stable since 1.0.0
Version 1.100.0-nightly
quodlibetor.github.io
...new ( ) ; match ( self , other ) { log_syntax ! ( ( & SingleUnitEnum :: One , & SingleUnitEnum :: One ) => { } ) } list } fn assert_equal_field_by_field ( & self , other : & SingleUnitEnum ) { let errs = self . fields_not_equal ( other ) ; if errs . len ( ) > 0 { let mut errmsg = String :: from ( "\n Items are not equal:\n" ) ; for field_err in errs { errmsg . push_str...
News & Blog Posts
2017-01-17
~9 min read