I'm using this repo to collect short Rust programs that I've written to solve specific problems when working on larger projects. e.g., to add multi-threading. I'm still learning Rust so the code can undoubtedly be improved. The repo is only intended for my use, but it's public on the off-chance it is useful to others.
Each snippet is in its own Cargo crate, which also means its own sub-directory. If you are at the top level and using Bash, a snippet can be run with:
cargo run -p thread-workerAlternatively, you can cd into a crate and use:
cargo run| Directory Name | Snippet Description |
|---|---|
| generic-struct-functions | Demonstrates the ability of a generic struct to have different implementations of a function with the same name but for different types. |
| thread-worker | A simple, multi-threaded worker. Chapter 20.3 of The Rust Programming Language has a more generic example along similar lines. |