rust.code-maven.com
...path, match
Setting status to 404 page not found. with_status_code, with_header, path.
Tiny HTTP redirect URL. with_header, Header, HeaderField, Request, Response.
Gabor Szabo, the author of the Rust Maven web site maintains several Open source projects in Rust
and while he still feels he has tons...
Rust Walkthroughs
2023-12-20
~1 min read
xion.io
...Option<String>
) -> Box<Stream<Item=Item, Error=Box<Error>>>
{
let client = Client::new(handle);
Box::new(stream::unfold(after, move |cont_token| {
let url = match cont_token {
Some(ct) => format!("{}?after={}", URL, ct),
None => return None,
};
let req = Request::new(Method::Get, url.parse().unwrap());
Some(client.request(req).from...
News & Blog Posts
2018-01-30
~11 min read
kerkour.com
...handling job({}): {}", job_id, &err);
queue.fail_job(job_id).await
}
};
match res {
Ok(_) => {}
Err(err) => {
println!("run_worker: deleting / failing job: {}", &err);
}
}
})
.await;
// sleep not to overload our database
tokio::time::sleep(Duration::from_millis(125)).await;
}
}
async fn handle_job(job: Job) -> Result<(), crate::Error> {
match job.message...
Rust Walkthroughs
2021-09-08
~6 min read
wiredforge.com
...Instead
// of having a series of `if`s, we instead use a single `match` statement
match v {
// if 1, we have a special case, we can return the `Ok`
// value with the maximum page size
1 => Ok(PageSize(65_536u32)),
// If we find 0 or 2-511, we found and...
Learn Standard Rust
2020-09-16
~16 min read
docs.rs
...expect("failed to execute process"); } } Simple Fork Example use fork::{fork, Fork, waitpid, WIFEXITED, WEXITSTATUS}; match fork() { Ok(Fork::Parent(child)) => { println!("Parent process, child PID: {}", child); // Wait for child and check exit status match waitpid(child) { Ok(status) => { if WIFEXITED(status) { println!("Child exited with code: {}", WEXITSTATUS(status)); } } Err...
Crate
v0.12.0
2026-11-16
crates.io
...new(("sample.tao", 11..48)) .with_message(format!( "The values are outputs of this {} expression", "match".fg(out), )) .with_color(out), ) .with_note(format!( "Outputs of {} expressions must coerce to the same type", "match".fg(out) )) .finish() .print(("sample.tao", Source::from(include_str!("sample.tao")))) .unwrap(); } See examples/ for...
Crate
v0.6.0
2025-10-28
doc.rust-lang.org
pub struct WriterPanicked
...io::Result<()> { panic!() }
}
let mut stream = BufWriter::new(PanickingWriter);
write!(stream, "some data").unwrap();
let result = catch_unwind(AssertUnwindSafe(|| {
stream.flush().unwrap()
}));
assert!(result.is_err());
let (recovered_writer, buffered_data) = stream.into_parts();
assert!(matches!(recovered_writer, PanickingWriter));
assert_eq!(buffered_data.unwrap_err().into_inner(), b"some data");
struct
alloc
Stable since 1.56.0
Version 1.100.0-nightly
dev.to
...impl AgentError {
pub fn is_retryable(&self) -> bool {
matches!(
self,
Self::Network(_) | Self::Provider { status: Some(500..=599), .. }
)
}
pub fn is_client_error(&self) -> bool {
matches!(self, Self::Provider { status: Some(s), .. } if *s >= 400 && *s < 500)
}
}
Enter fullscreen mode
Exit fullscreen mode
This was one of the things Rust...
Project/Tooling Updates
2026-03-11
~5 min read
www.coralbark.net
...The first version of my Python script just tried to match a regular expression against each line. It took over 4 minutes on my sample data, so I made a few tweaks (e.g. I noticed I was compiling the regular expression for each line). It still took over 4...
Observations/Thoughts
2020-10-21
~4 min read
rust-analyzer.github.io
#9123 (first contribution) add Gentoo installation instructions.
#9091 fix opening single files.
#8717, #9105 update match checking algorithm.
#9090 fix type inference with arbitrary self types.
#9130 make prefix/suffix parameter inlay hint hiding heuristic is more strict.
#9079 don’t take the parent kind of trailing attributes in attribute...
Project/Tooling Updates
2021-06-09
~1 min read
arXiv
arxiv.org
...a callback may publish mid-execution, and multi-input callbacks let developers choose topic-matching policies. Thus preserving DAG semantics relies on conventions; once violated, the model collapses. We propose the Function-as-Subtask (FasS) API, which expresses each subtask as a function whose arguments/return values are the subtask...
Operating Systems
Takahiro Ishikawa-Aso, Atsushi Yano, Yutaro Kobayashi et al.
2025-11-11
arXiv:2511.08297
github.com
...use parity_tokio_ipc::Endpoint; use futures::stream::StreamExt; // For testing purposes only - instead, use a path to an actual socket or a pipe let addr = parity_tokio_ipc::dummy_endpoint(); let server = async move { Endpoint::new(addr) .incoming() .expect("Couldn't set up server") .for_each(|conn| async { match...
Crate
v0.9.0
2021-07-06
doc.rust-lang.org
pub struct PoisonError<T>
...Examples
use std::sync::{Arc, Mutex};
use std::thread;
let mutex = Arc::new(Mutex::new(1));
// poison the mutex
let c_mutex = Arc::clone(&mutex);
let _ = thread::spawn(move || {
let mut data = c_mutex.lock().unwrap();
*data = 2;
panic!();
}).join();
match mutex.lock() {
Ok(_) => unreachable!(),
Err(p_err) => {
let data...
struct
std
Stable since 1.0.0
Version 1.100.0-nightly
xd009642.github.io
Archived: primary link replaced with an archive on 2026-09-12T17:24:53.882Z (UTC; replacement date, not snapshot date)
...Error,
{
let mut start = None;
while let Some(Ok(msg)) = receiver.next().await {
if let Ok(text) = msg.into_text() {
match serde_json::from_str::<RequestMessage>(&text) {
Ok(RequestMessage::Start(start_msg)) => {
info!(start=?start, "Initialising streamer");
start = Some(start_msg);
break;
}
Ok(RequestMessage::Stop(_)) => {
warn!("Unexpected stop received as...
Rust Walkthroughs
2025-01-22
~11 min read
git-cliff.org
...See #555 for an example.
✂️ Trim Text
We changed the commit parser behavior to always trim the text (commit message, body, etc.) before matching it with a regex.
This means that you will be able to use $ in the regex for matching until the end.
For example:
[git]commit_parsers...
Project/Tooling Updates
2024-04-03
~2 min read
docs.rs
...The "Type", "Subtype" and "BaseFont" tags // are straight out of the PDF spec. // // The dictionary macro is a helper that allows complex // key-value relationships to be represented in a simpler // visual manner, similar to a match statement. // A dictionary is implemented as an IndexMap of Vec<u8>, and Object...
Crate
v0.47.0
2026-11-04
rust-analyzer.github.io
#4065, #4128 complete unqualified enum variants
#4105 code completion for attributes.
#3954 we now pre-select completion variant if it matches the expected type.
#4006 syntax highlighting for format strings
#4069, #4070, #4158 improve documentation.
#4098 add setup instructions for YouCompleteMe.
#4082 implement rust-analyzer --help.
#4090 fix naming of...
News & Blog Posts
2020-05-05
~1 min read
crates.io
...impl MyBehavior for MyBehaviorEnum { fn my_trait_method(&self) { match self { MyImplementorA(inner) => inner.my_trait_method(), MyImplementorB(inner) => inner.my_trait_method(), } } } Additional trait methods would be expanded accordingly, and additional enum variants would correspond to additional match arms in each method definition. It's easy to see how...
Crate
v0.3.13
2024-03-28
docs.rs
...Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break> { match self { Self::A() => {} Self::B(_1, _2) => { _1.visit(visitor)?; _2.visit(visitor)?; } Self::C { named } => { named.visit(visitor)?; } } ControlFlow::Continue(()) } } Some types may wish to call a corresponding method on the visitor: #[derive(Visit, VisitMut)] #[visit(with = "visit_expr")] enum...
Crate
v0.7.0
2026-11-09
durka.github.io
...fn main() {
let dir = PathBuf::from(env::args().skip(1).next().unwrap());
match local_du(&dir) {
Ok(bytes) => println!("{} {}", bytes, dir.display()),
Err(error) => println!("ERROR: {:?}", error),
}
}
v1: quick and dirty
Here is the first version of my local_du function. You’ll notice that I like chaining iterators. The...
News & Blog Posts
2017-08-15
~7 min read