Code Snippets

Language: Rust

Error Handling with anyhow

Use anyhow::Result and the `?` operator for ergonomic errors.

Author: chris

Async with Tokio Runtime

Run concurrent async tasks with tokio::spawn and join.

Author: chris

Spawn an OS Thread in Rust

Use std::thread::spawn and join handles for parallel work.

Author: chris

Iterate a Directory in Rust

Walk a single directory level with std::fs::read_dir.

Author: chris

Sort Vec by Key in Rust

Sort a Vec of structs by one field using sort_by_key.

Author: chris