Struct core::ops::RangeFull 1.0.0[−][src]
pub struct RangeFull;
Expand description
无限制范围 (..)。
RangeFull 主要用作 slicing index,其简写为 ..。
它不能用作 Iterator,因为它没有起点。
Examples
.. 语法是 RangeFull:
assert_eq!((..), std::ops::RangeFull);Run
它没有 IntoIterator 实现,因此不能直接在 for 循环中使用它。
这不会编译:
for i in .. { // ... }Run
用作 slicing index 时,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 ]);Run
Trait Implementations
开始索引绑定。 Read more
fn contains<U: ?Sized>(&self, item: &U) -> bool where
T: PartialOrd<U>,
U: PartialOrd<T>,
1.35.0[src]
fn contains<U: ?Sized>(&self, item: &U) -> bool where
T: PartialOrd<U>,
U: PartialOrd<T>,
1.35.0[src]如果范围中包含 item,则返回 true。 Read more
type Output = [T]
type Output = [T]
方法返回的输出类型。
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]。
type Output = str
type Output = str
方法返回的输出类型。
slice_index_methods)返回此位置输出的共享引用,而不执行任何边界检查。
即使未使用所得的引用,使用越界索引或悬空的 slice 指针调用此方法也是 [undefined 行为]。 Read more
slice_index_methods)返回此位置输出的变量引用,而不执行任何边界检查。
即使未使用所得的引用,使用越界索引或悬空的 slice 指针调用此方法也是 [undefined 行为]。 Read more
slice_index_methods)返回此位置输出的共享引用,如果越界则会触发 panic。 Read more