Struct core::ops::RangeFull 1.0.0[−][src]
pub struct RangeFull;Expand description
无限制范围 (..)。
RangeFull 主要用作 切片索引,其简写为 ..。
它不能用作 Iterator,因为它没有起点。
Examples
.. 语法是一个 RangeFull:
assert_eq!((..), std::ops::RangeFull);Run它没有 IntoIterator 实现,因此不能直接在 for 循环中使用它。
这不会编译:
for i in .. {
// ...
}Run用作 切片索引 时,RangeFull 产生完整的阵列作为切片。
let arr = [0, 1, 2, 3, 4];
assert_eq!(arr[ .. ], [0, 1, 2, 3, 4]); // 这是 `RangeFull`
assert_eq!(arr[ .. 3], [0, 1, 2 ]);
assert_eq!(arr[ ..=3], [0, 1, 2, 3 ]);
assert_eq!(arr[1.. ], [ 1, 2, 3, 4]);
assert_eq!(arr[1.. 3], [ 1, 2 ]);
assert_eq!(arr[1..=3], [ 1, 2, 3 ]);RunTrait Implementations
slice_index_methods)返回此位置输出的共享引用,而不执行任何边界检查。
即使未使用所得的引用,使用越界索引或悬垂的 slice 指针调用此方法也是 [undefined 行为]。 Read more
slice_index_methods)返回此位置输出的变量引用,而不执行任何边界检查。
即使未使用所得的引用,使用越界索引或悬垂的 slice 指针调用此方法也是 [undefined 行为]。 Read more
slice_index_methods)返回此位置输出的共享引用,如果越界则会触发 panic。 Read more
使用语法 &self[..] 或 &mut self[..] 实现子字符串切片。
返回整个字符串的切片,即返回 &self 或 &mut self。相当于 &self[0 .. len] 或 &mut self[0 .. len].
与其他索引操作不同,此操作永远不能 panic。
此运算为 O(1)。
在 1.20.0 之前,Index 和 IndexMut 的直接实现仍支持这些索引操作。
等效于 &self[0 .. len] 或 &mut self[0 .. len]。
slice_index_methods)返回此位置输出的共享引用,而不执行任何边界检查。
即使未使用所得的引用,使用越界索引或悬垂的 slice 指针调用此方法也是 [undefined 行为]。 Read more
slice_index_methods)返回此位置输出的变量引用,而不执行任何边界检查。
即使未使用所得的引用,使用越界索引或悬垂的 slice 指针调用此方法也是 [undefined 行为]。 Read more
slice_index_methods)返回此位置输出的共享引用,如果越界则会触发 panic。 Read more