Example Code and Templates

Small Examples and Exercises

You can use the Rust Playground↗ to quickly test snippets of code.

Notable Rust Code Repositories

Reading code is the fastest way to learn idiomatic Rust. Use the following links to locate useful Rust repositories.

Lists of Popular Rust Repositories

"RealWorld" Examples

The "Real World" Example App(website)↗, dubbed "the mother of all demo apps", is a fullstack medium.com↗ clone implemented in many languages and frameworks. A list of Rust implementations is found here↗.

For example, realworld-rust-axum-sqlx↗ is a full-stack RealWorld implementation using axum, sqlx, and yew.

ChromeOS Virtual Machine Monitor

The ChromeOS Virtual Machine Monitor (github)↗ is written in Rust, with over 300k LoC. Its repository contains many well-documented crates. There is a book↗ and thorough documentation↗ for all crates.

Build Your Own X

Build Your Own X↗ is a compilation of well-written, step-by-step guides for re-creating your favorite technologies from scratch. It includes several Rust projects.

Source Code for Rust Books

You may also consult the code examples from various Rust books:

Templates

cargo-generate cargo-generate~crates.io cargo-generate~repo cargo-generate~lib.rs

cargo-generate↗ helps you get up and running quickly with a new Rust project by leveraging a pre-existing git repository as a template.

You will find cargo-generate-ready templates in this list↗. Beyond cargo-generate, search for Rust projects on GitHub↗.

For example, you will find a full template for a REST API written in Rust, engineered for maximum testability in the rust-rest↗ repo.