-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from getKongBai/master
KongBai的报告
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: 2024 rcore-os第一阶段 Rust基础 报告 | ||
date: 2024-04-23 14:37:01 | ||
tags: [ rust,基础,rcore ] | ||
--- | ||
|
||
# 2024 rcore-os第一阶段 Rust基础 报告 | ||
|
||
### 作者:李明宇(getKongBai) | ||
|
||
## 学习内容难点 | ||
|
||
### Rust所有权与生命周期 | ||
|
||
Rust的所有权要求每个值只允许有一个变量拥有其所有权,引用类似于并发的读写锁,读引用可以同时存在,但是写引用不能同时存在、也不能与读引用同时存在,写独占读共享。Rust的生命周期确保引用在有效期内是有效的。 | ||
|
||
### Rust智能指针 | ||
|
||
Rust的智能指针包括但不限于Box、Rc和RefCell,Box用于在堆上分配内存,Rc用于在堆上共享内存 | ||
|
||
### Rust并发 | ||
|
||
Rust的所有权机制在并发时完全就可以当锁用,但也因此:通过通讯来共享内存、而不是通过共享内存来通讯。 | ||
|
||
### Rust宏 | ||
|
||
学的很少,一种基于语法的元编程,需要用模式匹配解语法树 | ||
|
||
### Rust链表 | ||
|
||
最折磨的一集,引用来回变化,满地的unsafe | ||
|
||
## 写Rust的小技巧 | ||
|
||
### 少用可变变量 | ||
|
||
可变变量需要来回考虑可变引用 | ||
|
||
### 用函数式编程解决问题 | ||
|
||
使用函数和递归可以解决很多变量所有权问题和引用的相互冲突(尽量写纯函数)。写数据结构的时候很多代码第一开始我用循环,结果被各种引用折磨,后来用递归实现可以少考虑很多引用问题 |