• Stars
    star
    12,168
  • Rank 2,681 (Top 0.06 %)
  • Language
    Rust
  • License
    Creative Commons ...
  • Created over 6 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

English | 中文

Practice Rust with challenging examples, exercises and projects

Stars Count studyrut LICENSE

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

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.

🏅 Contributors

Thanks to all of our contributors!


🏆 Special thanks to our English editor:


Tanish-Eagle

Running locally

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

  • Clone the repo
$ git clone [email protected]:sunface/rust-by-practice.git
  • Install mdbook using Cargo
$ cargo install mdbook
  • For Book in English
$ cd rust-by-practice && mdbook serve en/
  • For Book in Chinese
$ 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.

// 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.

// 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 => (),
    }
}

More Repositories

1

rust-course

“连续八年成为全世界最受喜爱的语言,无 GC 也无需手动内存管理、极高的性能和安全性、过程/OO/函数式编程、优秀的包管理、JS 未来基石" — 工作之余的第二语言来试试 Rust 吧。本书拥有全面且深入的讲解、生动贴切的示例、德芙般丝滑的内容,这可能是目前最用心的 Rust 中文学习教程 / Book
Rust
25,466
star
2

datav

📊https://datav.io is a modern APM, provide observability for your business, application and infrastructure. It's also a lightweight alternative to Grafana.
TypeScript
2,697
star
3

codecc

零一次元:记录个人关于技术、管理、经济和社会的深度思考
1,816
star
4

tokio-course

该书是中文 Rust 教程 <<Rust语言圣经>> 中的镜像专题,高质量手翻并扩展了 tokio 官网的教程, 深入讲述了如何编写 Rust 高并发异步程序
142
star
5

SRE-course

这是一门包罗万象但又井然有序、既有岁月沉淀但又非常潮流的 SRE (Site Reliability Engineer) 教程。
Handlebars
137
star
6

too-many-lists

中文书名<<手把手实现 Rust 链表>>,高质量手翻 Too Many Linked Lists, 是一本非常好的 Rust 实践学习教程
103
star
7

new-rusty-book

A curated list of recipes and repos that can be used to build your rusty projects. Rusty Book = Cookbook + Awesome Rust!
Handlebars
45
star
8

blogs

大道至简,技术如歌,欢迎来到Sunface的个人博客
JavaScript
39
star
9

beat-ai

🤖 Beat AI,机器学习的入门百科全书。 🤖 书中有循序渐进的示例及技术图解。 🤖 与其它理工科天书不同,本书的目标是从宏观角度切入、以高屋建瓴的方式讲透何为机器学习以及后续的学习路线。 🤖 我们希望抛开复杂的数学公式、逻辑,做一套任何人都能看懂的机器学习教程。
23
star
10

war-book

War = Wasm And Rust
11
star
11

sunface

5
star
12

zh.practice.rs

该仓库仅用于存放 gh-pages 网页的静态资源,大家如果想要关注,请访问源仓库的地址 https://github.com/sunface/rust-exercise
HTML
5
star
13

Rubot-Test

1
star
14

datav-for-counting

TypeScript
1
star