Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

rust-by-practice

> DevOps
Open source

Learning Rust By Practice, narrowing the gap between beginner and skilled-dev through challenging examples, exercises and projects.

14.7K stars0 likes0 views
WebsiteGitHub

About

Learning Rust By Practice, narrowing the gap between beginner and skilled-dev through challenging examples, exercises and projects.

Practice Rust with challenging examples, exercises and projects

This book was designed for easily diving into and getting skilled with Rust It's very easy to use. All you need to do is to make each exercise compile without ERRORS and Panics!

Reading online

  • https://practice.rs

Features

Part of our examples and exercises are borrowed from Rust By Example, thanks for your great works!

Although they are so awesome, we have our own secret weapons :)

  • There are three parts in each chapter: examples, exercises and practices

  • Besides examples, we have a lot of exercises, you can Read, Edit and Run them ONLINE

  • Covering nearly all aspects of Rust, such as async/await, threads, sync primitives, optimizing, standard libraries, tool chain, data structures and algorithms etc.

  • Every exercise has its own solutions

  • The overall difficulties are a bit higher and from easy to super hard: easy 🌟 medium 🌟🌟 hard 🌟🌟🌟 super hard 🌟🌟🌟🌟

What we want to do is fill in the gap between learning and getting started with real projects.

Running locally

We use mdbook building our exercises. You can run locally with below steps:

  • Clone the repo
bash
$ git clone https://github.com/sunface/rust-by-practice
  • Install mdbook using Cargo
bash
$ cargo install mdbook
  • For Book in English
bash
$ cd rust-by-practice && mdbook serve en/
  • For Book in Chinese
bash
$ cd rust-by-practice && mdbook serve zh-CN/

Some of our exercises

🌟🌟🌟 Tuple struct looks similar to tuples, it has added meaning the struct name provides but has no named fields. It's useful when you want give the whole tuple a name, but don't care the fields's names.

rust

// fix the error and fill the blanks
struct Color(i32, i32, i32);
struct Point(i32, i32, i32);
fn main() {
    let v = Point(___, ___, ___);
    check_color(v);
}

fn check_color(p: Color) {
    let (x, _, _) = p;
    assert_eq!(x, 0);
    assert_eq!(p.1, 127);
    assert_eq!(___, 255);
 }

🌟🌟 Within the destructuring of a single variable, both by-move and by-reference pattern bindings can be used at the same time. Doing this will result in a partial move of the variable, which means that parts of the variable will be moved while other parts stay. In such a case, the parent variable cannot be used afterwards as a whole, however the parts that are only referenced (and not moved) can still be used.

rust

// fix errors to make it work
#[derive(Debug)]
struct File {
    name: String,
    data: String,
}
fn main() {
    let f = File {
        name: String::from("readme.md"),
        data: "Rust By Practice".to_string()
    };

    let _name = f.name;

    // ONLY modify this line
    println!("{}, {}, {:?}",f.name, f.data, f);
}

🌟🌟 A match guard is an additional if condition specified after the pattern in a match arm that must also match, along with the pattern matching, for that arm to be chosen.


// fill in the blank to make the code work, `split` MUST be used
fn main() {
    let num = Some(4);
    let split = 5;
    match num {
        Some(x) __ => assert!(x < split),
        Some(x) => assert!(x >= split),
        None => (),
    }
}

Issues· 68 open

View all issuesOpen on GitHub
  • #583

    cd rust-by-practice && mdbook serve en/ this command is error for me

    Updated Jul 27, 2026
  • #581

    通过mdbook serve zh-CN/打开时遇到error

    Updated Mar 5, 2026
  • #578

    [Site]: Chinese site 404

    Updated Feb 5, 2026
  • #566

    https://practice.rs outdated

    Updated Nov 18, 2025
  • #564

    中文版本代码块显示问题

    Updated Nov 10, 2025
  • #500

    集合类型-hashmap 第二题答案有误

    Updated Oct 29, 2025
  • #573

    Upgrade Rust version to 2021 for Chinese version

    Updated Oct 29, 2025
  • #572

    `From/Intro` should be `From/Into`

    Updated Oct 29, 2025
  • #570

    the second method is the same as the first one

    Updated Oct 25, 2025
  • #395

    Building text editor tutorial link not working

    Updated Aug 19, 2025

> Tags

Rustexampleexamplesexerciseexercises

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 1, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理