docs: update comments

This commit is contained in:
CarrotDLaw 2024-05-10 18:03:09 +08:00
parent 7a9c4dfdc5
commit 665b61bfa2
5 changed files with 11 additions and 9 deletions

View File

@ -78,7 +78,8 @@ fn main() {
print_util::print_array(&arr);
// 在 Rust 中,指定长度时([i32; 5])为数组
// 由于 Rust 的数组被设计为在编译期确定长度,因此只能使用常量来指定长度
// 为了方便实现扩容 extend() 方法,以下将(Vec) 看作数组Array也是rust一般情况下使用动态数组的类型
// Vec 是 Rust 一般情况下使用动态数组的类型
// 为了方便实现扩容 extend() 方法,以下将 Vec 看作数组Array
let nums: Vec<i32> = vec![1, 3, 2, 5, 4];
print!("\n数组 nums = ");
print_util::print_array(&nums);

View File

@ -96,8 +96,8 @@
let arr: [i32; 5] = [0; 5]; // [0, 0, 0, 0, 0]
// 在 Rust 中,指定长度时([i32; 5])为数组
// 由于 Rust 的数组被设计为在编译期确定长度,因此只能使用常量来指定长度
// Vec 是 Rust 一般情况下使用动态数组的类型
// 为了方便实现扩容 extend() 方法,以下将 Vec 看作数组Array
// Vector 是 Rust 一般情况下使用动态数组的类型
// 为了方便实现扩容 extend() 方法,以下将 vector 看作数组array
let nums: Vec<i32> = vec![1, 3, 2, 5, 4];
```

View File

@ -97,8 +97,8 @@ Arrays can be initialized in two ways depending on the needs: either without ini
let slice: &[i32] = [0; 5];
// In Rust, specifying the length ([i32; 5]) denotes an array, while not specifying it (&[i32]) denotes a slice.
// Since Rust's arrays are designed to have compile-time fixed length, only constants can be used to specify the length.
// Vec is generally used as dynamic array in Rust
// For convenience in implementing the extend() method, the Vec will be considered as an Array here.
// Vectors are generally used as dynamic arrays in Rust.
// For convenience in implementing the extend() method, the vector will be considered as an array here.
let nums: Vec<i32> = vec![1, 3, 2, 5, 4];
```

View File

@ -76,9 +76,10 @@ fn main() {
let arr: [i32; 5] = [0; 5];
print!("陣列 arr = ");
print_util::print_array(&arr);
// 在 Rust 中,指定長度時([i32; 5])為陣列
// 在 Rust 中,指定長度时([i32; 5])爲陣列,不指定長度時(&[i32])爲切片
// 由於 Rust 的陣列被設計為在編譯期確定長度,因此只能使用常數來指定長度
// 為了方便實現擴容 extend() 方法,以下將(Vec) 看作陣列Array也是rust一般情況下使用動態陣列的型別
// Vec 是 Rust 一般情況下使用動態陣列的類型
// 為了方便實現擴容 extend() 方法,以下將 Vec 看作陣列Array
let nums: Vec<i32> = vec![1, 3, 2, 5, 4];
print!("\n陣列 nums = ");
print_util::print_array(&nums);

View File

@ -97,8 +97,8 @@
let slice: &[i32] = [0; 5];
// 在 Rust 中,指定長度时([i32; 5])爲陣列,不指定長度時(&[i32])爲切片
// 由於 Rust 的陣列被設計為在編譯期確定長度,因此只能使用常數來指定長度
// Vec 是 Rust 一般情況下使用動態陣列的類型
// 為了方便實現擴容 extend() 方法,以下將 Vec 看作陣列(Array
// Vector 是 Rust 一般情況下使用動態陣列的類型
// 為了方便實現擴容 extend() 方法,以下將 Vec 看作陣列(array
let nums: Vec<i32> = vec![1, 3, 2, 5, 4];
```