mirror of
https://github.com/RustyCab/LearnRustEasy.git
synced 2026-02-04 02:33:24 +08:00
Update chapter_3_7_3.md
This commit is contained in:
@@ -45,3 +45,22 @@ fn main() {
|
||||
&str和&String的内存布局如下:
|
||||
|
||||

|
||||
|
||||
#### 3. 其它Slice
|
||||
数组的Slice,如下:
|
||||
```Rust
|
||||
fn main() {
|
||||
let a: [u32; 5] = [1, 2, 3, 4, 5];
|
||||
let b = &a[1..3];
|
||||
println!("b: {:?}", b);
|
||||
}
|
||||
```
|
||||
Vec的Slice,如下:
|
||||
```Rust
|
||||
fn main() {
|
||||
let v: Vec<u32> = vec![1, 2, 3, 4, 5];
|
||||
let b = &v[1..3];
|
||||
println!("b: {:?}", b);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user