Rust in an Hour | Notes / RUST | 氵工的博客

Rust in an Hour

发表于 2026-03-25 14:47 151 字 1 min read

729DHS avatar

729DHS

氵工的博客 - 分享单片机开发、Linux、机器人技术、RL强化学习与嵌入式项目的学习笔记与实践记录。涵盖STM32、FreeRTOS、Rust、R语言等技术的详细教程与调试经验。

Google 未收录此页面? 在 Search Console 中请求编入索引
Rust in an Hour reading notes

Rust in an Hour

Delete Element

The underscore is a special name - or rather, a “lack of name”. It basically means to throw away something:_

// this does *nothing* because 42 is a constant
let _ = 42;

// this calls `get_thing` but throws away its result
let _ = get_thing();

Tuples

the format of tuples is “(a,b,c…)” , the most usage are similar to tuples in Python:

let pair = ('a', 17);
pair.0; // this is 'a'
pair.1; // this is 17

//you can define their type

let pairs:(i32, i32,char) = (1,2,'a');

the content of tuples are static

Destructuring Tuples

example:

let (x, y, z) = (1, 2, 3);

Statements

let x = vec![1, 2, 3, 4, 5, 6, 7, 8]
    .iter()
    .map(|x| x + 3)
    .fold(0, |x, y| x + y);

Declare Function