zoniony / zoniony.github.io

blog
1 stars 0 forks source link

rust抄书之道 #3

Open zoniony opened 4 years ago

zoniony commented 4 years ago

这本书很不错 抄书笔记

3.类型系统

3.1 通用概念

3.1.1类型系统的作用

3.1.2 类型系统的分类

3.1.3 类型系统与多态性

3.2 Rust类型系统概述

3.2.1 类型大小

3.2.2 类型推导

3.3泛型

3.3.1 泛型函数

3.3.2 泛型返回值自动推导

3.4 深入trait

3.4.1 接口抽象

3.4.2 泛型约束

3.4.3 抽象类型

3.5 类型转换

3.5.1 Deref解引用

3.5.2 as操作符

3.5.3 from和into

4. 内存管理

4.1 通用概念

4.2 Rust资源管理

4.2.1 变量和函数

4.2.2 智能指针与RALL

4.2.3 内存泄漏与内存安全

4.2.4 复合类型的内存分配和布局

struct A {
  a: u32,
  b: Box<u64>,
}

l5d3oc

struct B(i32, f64, char);
struct N;
enum E {
  H(32),
  M(Box<u32>),
}

4l2sqm

5.所有权系统

5.1 通用概念

5.2 所有权机制

5.3 绑定、作用域和生命周期

5.3.1 不可变与可变

5.3.2 绑定的时间属性 生命周期

5.4 所有权借用

5.5 生命周期参数

5.5.1 显示生命周期参数

5.5.2 省略生命周期参数

fn print(s: &str);                                           // 省略
fn print<'a>(s: &'a str);                                   // 展开
fn debug(lvl: uint, s: &str);                              // 省略
fn debug<'a>(lvl: uint, s: &'a str);                      // 展开
fn substr(s: &str, until: uint) -> &str;                 // 省略
fn substr<'a>(s: &'a str, until: uint) -> &'a str;     // 展开
fn get_str() -> &str;                                   // 非法
fn frob(s: &str, t: &str) -> &str;                    // 非法
fn get_mut(&mut self) -> &mut T;                           // 省略
fn get_mut<'a>(&'a mut self) -> &'a mut T;              // 展开
/// // 省略
fn args<T:ToCStr>(&mut self, args: &[T]) -> &mut Command
/// // 展开
fn args<'a, 'b, T:ToCStr>(&'a mut self, args: &'b [T]) -> &'a mut Command
fn new(buf: &mut [u8]) -> BufWriter;                      // 省略
fn new<'a>(buf: &'a mut [u8]) -> BufWriter<'a>          // 展开

5.5.3 生命周期限定

5.5.4 trait对象的生命周期

​ TODO

6 函数,闭包和迭代器

6.1 函数

6.1.1 函数屏蔽

6.1.2 函数参数的匹配模式

6.1.3函数返回值

6.1.4 泛型函数

ZhangHanDong commented 4 years ago

震惊

zoniony commented 4 years ago

震惊

Σ(っ °Д °;)っ 草 被作者大大发现了

ZhangHanDong commented 4 years ago

加油