mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-23 04:29:41 +00:00
Update basic.md
change 标准 to 标注
This commit is contained in:
@ -77,7 +77,7 @@ fn print_one<'a>(x: &'a i32) {
|
|||||||
println!("`print_one`: x is {}", x);
|
println!("`print_one`: x is {}", x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 可变引用依然需要标准生命周期
|
// 可变引用依然需要标注生命周期
|
||||||
fn add_one<'a>(x: &'a mut i32) {
|
fn add_one<'a>(x: &'a mut i32) {
|
||||||
*x += 1;
|
*x += 1;
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ fn main() {
|
|||||||
#### Structs
|
#### Structs
|
||||||
6. 🌟
|
6. 🌟
|
||||||
```rust,editable
|
```rust,editable
|
||||||
/* 增加合适的生命周期标准,让代码工作 */
|
/* 增加合适的生命周期标注,让代码工作 */
|
||||||
|
|
||||||
// `i32` 的引用必须比 `Borrowed` 活得更久
|
// `i32` 的引用必须比 `Borrowed` 活得更久
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
Reference in New Issue
Block a user