Struct std::ops::RangeInclusive
1.26.0 · source · pub struct RangeInclusive<Idx> { /* private fields */ }
Expand description
范围包括 (start..=end
) 的上下边界。
RangeInclusive
start..=end
包含 x >= start
和 x <= end
的所有值。除非 start <= end
,否则为空。
这个迭代器是 fused,但是迭代完成后 start
和 end
的特定值是未指定的,除了 .is_empty()
之外,一旦不再产生值,就会返回 true
。
Examples
start..=end
语法是 RangeInclusive
:
assert_eq!((3..=5), std::ops::RangeInclusive::new(3, 5));
assert_eq!(3 + 4 + 5, (3..=5).sum());
Runlet arr = [0, 1, 2, 3, 4];
assert_eq!(arr[ .. ], [0, 1, 2, 3, 4]);
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 ]); // 这是 `RangeInclusive`
RunImplementations§
source§impl<Idx> RangeInclusive<Idx>
impl<Idx> RangeInclusive<Idx>
1.27.0 (const: 1.32.0) · sourcepub const fn new(start: Idx, end: Idx) -> RangeInclusive<Idx> ⓘ
pub const fn new(start: Idx, end: Idx) -> RangeInclusive<Idx> ⓘ
1.27.0 (const: 1.32.0) · sourcepub const fn start(&self) -> &Idx
pub const fn start(&self) -> &Idx
返回范围的下限 (包括下限)。
当使用包含范围进行迭代时,在迭代结束后未指定 start()
和 end()
的值。
若要确定包含范围是否为空,请使用 is_empty()
方法而不是比较 start() > end()
。
Note: 范围迭代到穷竭之后,此方法返回的值是不确定的。
Examples
assert_eq!((3..=5).start(), &3);
Run1.27.0 (const: 1.32.0) · sourcepub const fn end(&self) -> &Idx
pub const fn end(&self) -> &Idx
返回范围的上限 (包括上限)。
当使用包含范围进行迭代时,在迭代结束后未指定 start()
和 end()
的值。
若要确定包含范围是否为空,请使用 is_empty()
方法而不是比较 start() > end()
。
Note: 范围迭代到穷竭之后,此方法返回的值是不确定的。
Examples
assert_eq!((3..=5).end(), &5);
Run1.27.0 (const: unstable) · sourcepub fn into_inner(self) -> (Idx, Idx)
pub fn into_inner(self) -> (Idx, Idx)
source§impl<Idx> RangeInclusive<Idx>where
Idx: PartialOrd<Idx>,
impl<Idx> RangeInclusive<Idx>where Idx: PartialOrd<Idx>,
1.35.0 · sourcepub fn contains<U>(&self, item: &U) -> boolwhere
Idx: PartialOrd<U>,
U: PartialOrd<Idx> + ?Sized,
pub fn contains<U>(&self, item: &U) -> boolwhere Idx: PartialOrd<U>, U: PartialOrd<Idx> + ?Sized,
如果范围中包含 item
,则返回 true
。
Examples
assert!(!(3..=5).contains(&2));
assert!( (3..=5).contains(&3));
assert!( (3..=5).contains(&4));
assert!( (3..=5).contains(&5));
assert!(!(3..=5).contains(&6));
assert!( (3..=3).contains(&3));
assert!(!(3..=2).contains(&3));
assert!( (0.0..=1.0).contains(&1.0));
assert!(!(0.0..=1.0).contains(&f32::NAN));
assert!(!(0.0..=f32::NAN).contains(&0.0));
assert!(!(f32::NAN..=1.0).contains(&1.0));
Run迭代完成后,此方法总是返回 false
:
let mut r = 3..=5;
assert!(r.contains(&3) && r.contains(&5));
for _ in r.by_ref() {}
// 此处未指定精确的字段值
assert!(!r.contains(&3) && !r.contains(&5));
Run1.47.0 · sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
如果范围不包含任何项,则返回 true
。
Examples
assert!(!(3..=5).is_empty());
assert!(!(3..=3).is_empty());
assert!( (3..=2).is_empty());
Run如果任何一方都无法比拟,则范围为空:
assert!(!(3.0..=5.0).is_empty());
assert!( (3.0..=f32::NAN).is_empty());
assert!( (f32::NAN..=5.0).is_empty());
Run迭代完成后,此方法返回 true
:
let mut r = 3..=5;
for _ in r.by_ref() {}
// 此处未指定精确的字段值
assert!(r.is_empty());
RunTrait Implementations§
source§impl<Idx> Clone for RangeInclusive<Idx>where
Idx: Clone,
impl<Idx> Clone for RangeInclusive<Idx>where Idx: Clone,
source§impl<Idx> Debug for RangeInclusive<Idx>where
Idx: Debug,
impl<Idx> Debug for RangeInclusive<Idx>where Idx: Debug,
source§impl<A> DoubleEndedIterator for RangeInclusive<A>where
A: Step,
impl<A> DoubleEndedIterator for RangeInclusive<A>where A: Step,
source§fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> Rwhere
RangeInclusive<A>: Sized,
F: FnMut(B, <RangeInclusive<A> as Iterator>::Item) -> R,
R: Try<Output = B>,
fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> Rwhere RangeInclusive<A>: Sized, F: FnMut(B, <RangeInclusive<A> as Iterator>::Item) -> R, R: Try<Output = B>,
Iterator::try_fold()
的反向版本:它从迭代器的后面开始接收元素。 Read moresource§fn rfold<AAA, FFF>(self, init: AAA, fold: FFF) -> AAAwhere
FFF: FnMut(AAA, <RangeInclusive<A> as Iterator>::Item) -> AAA,
fn rfold<AAA, FFF>(self, init: AAA, fold: FFF) -> AAAwhere FFF: FnMut(AAA, <RangeInclusive<A> as Iterator>::Item) -> AAA,
source§fn advance_back_by(&mut self, n: usize) -> Result<(), NonZeroUsize>
fn advance_back_by(&mut self, n: usize) -> Result<(), NonZeroUsize>
iter_advance_by
#77404)n
元素从后向前推进迭代器。 Read moresource§impl ExactSizeIterator for RangeInclusive<i16>
impl ExactSizeIterator for RangeInclusive<i16>
source§impl ExactSizeIterator for RangeInclusive<i8>
impl ExactSizeIterator for RangeInclusive<i8>
source§impl ExactSizeIterator for RangeInclusive<u16>
impl ExactSizeIterator for RangeInclusive<u16>
source§impl ExactSizeIterator for RangeInclusive<u8>
impl ExactSizeIterator for RangeInclusive<u8>
source§impl<Idx> Hash for RangeInclusive<Idx>where
Idx: Hash,
impl<Idx> Hash for RangeInclusive<Idx>where Idx: Hash,
source§impl<A> Iterator for RangeInclusive<A>where
A: Step,
impl<A> Iterator for RangeInclusive<A>where A: Step,
source§fn try_fold<B, F, R>(&mut self, init: B, f: F) -> Rwhere
RangeInclusive<A>: Sized,
F: FnMut(B, <RangeInclusive<A> as Iterator>::Item) -> R,
R: Try<Output = B>,
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> Rwhere RangeInclusive<A>: Sized, F: FnMut(B, <RangeInclusive<A> as Iterator>::Item) -> R, R: Try<Output = B>,
source§fn fold<AAA, FFF>(self, init: AAA, fold: FFF) -> AAAwhere
FFF: FnMut(AAA, <RangeInclusive<A> as Iterator>::Item) -> AAA,
fn fold<AAA, FFF>(self, init: AAA, fold: FFF) -> AAAwhere FFF: FnMut(AAA, <RangeInclusive<A> as Iterator>::Item) -> AAA,
fold
到一个累加器中,返回最终结果。 Read moresource§fn is_sorted(self) -> bool
fn is_sorted(self) -> bool
is_sorted
#53485)source§fn next_chunk<const N: usize>(
&mut self
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
fn next_chunk<const N: usize>( &mut self ) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where Self: Sized,
iter_next_chunk
#98326)N
值的数组。 Read moresource§fn advance_by(&mut self, n: usize) -> Result<(), NonZeroUsize>
fn advance_by(&mut self, n: usize) -> Result<(), NonZeroUsize>
iter_advance_by
#77404)n
元素使迭代器前进。 Read more1.28.0 · source§fn step_by(self, step: usize) -> StepBy<Self> ⓘwhere
Self: Sized,
fn step_by(self, step: usize) -> StepBy<Self> ⓘwhere Self: Sized,
1.0.0 · source§fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> ⓘwhere
Self: Sized,
U: IntoIterator<Item = Self::Item>,
fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> ⓘwhere Self: Sized, U: IntoIterator<Item = Self::Item>,
1.0.0 · source§fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> ⓘwhere
Self: Sized,
U: IntoIterator,
fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> ⓘwhere Self: Sized, U: IntoIterator,
source§fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G> ⓘwhere
Self: Sized,
G: FnMut() -> Self::Item,
fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G> ⓘwhere Self: Sized, G: FnMut() -> Self::Item,
iter_intersperse
#79524)separator
生成的项放在原始迭代器的相邻项之间。 Read more1.0.0 · source§fn map<B, F>(self, f: F) -> Map<Self, F> ⓘwhere
Self: Sized,
F: FnMut(Self::Item) -> B,
fn map<B, F>(self, f: F) -> Map<Self, F> ⓘwhere Self: Sized, F: FnMut(Self::Item) -> B,
1.21.0 · source§fn for_each<F>(self, f: F)where
Self: Sized,
F: FnMut(Self::Item),
fn for_each<F>(self, f: F)where Self: Sized, F: FnMut(Self::Item),
1.0.0 · source§fn filter<P>(self, predicate: P) -> Filter<Self, P> ⓘwhere
Self: Sized,
P: FnMut(&Self::Item) -> bool,
fn filter<P>(self, predicate: P) -> Filter<Self, P> ⓘwhere Self: Sized, P: FnMut(&Self::Item) -> bool,
1.0.0 · source§fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> ⓘwhere
Self: Sized,
F: FnMut(Self::Item) -> Option<B>,
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> ⓘwhere Self: Sized, F: FnMut(Self::Item) -> Option<B>,
1.0.0 · source§fn enumerate(self) -> Enumerate<Self> ⓘwhere
Self: Sized,
fn enumerate(self) -> Enumerate<Self> ⓘwhere Self: Sized,
1.0.0 · source§fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> ⓘwhere
Self: Sized,
P: FnMut(&Self::Item) -> bool,
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> ⓘwhere Self: Sized, P: FnMut(&Self::Item) -> bool,
1.0.0 · source§fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> ⓘwhere
Self: Sized,
P: FnMut(&Self::Item) -> bool,
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> ⓘwhere Self: Sized, P: FnMut(&Self::Item) -> bool,
1.57.0 · source§fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> ⓘwhere
Self: Sized,
P: FnMut(Self::Item) -> Option<B>,
fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> ⓘwhere Self: Sized, P: FnMut(Self::Item) -> Option<B>,
1.0.0 · source§fn skip(self, n: usize) -> Skip<Self> ⓘwhere
Self: Sized,
fn skip(self, n: usize) -> Skip<Self> ⓘwhere Self: Sized,
n
个元素的迭代器。 Read more1.0.0 · source§fn take(self, n: usize) -> Take<Self> ⓘwhere
Self: Sized,
fn take(self, n: usize) -> Take<Self> ⓘwhere Self: Sized,
n
元素,如果底层迭代器提前结束,则产生更少的元素。 Read more1.0.0 · source§fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> ⓘwhere
Self: Sized,
F: FnMut(&mut St, Self::Item) -> Option<B>,
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> ⓘwhere Self: Sized, F: FnMut(&mut St, Self::Item) -> Option<B>,
1.0.0 · source§fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> ⓘwhere
Self: Sized,
U: IntoIterator,
F: FnMut(Self::Item) -> U,
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> ⓘwhere Self: Sized, U: IntoIterator, F: FnMut(Self::Item) -> U,
1.0.0 · source§fn inspect<F>(self, f: F) -> Inspect<Self, F> ⓘwhere
Self: Sized,
F: FnMut(&Self::Item),
fn inspect<F>(self, f: F) -> Inspect<Self, F> ⓘwhere Self: Sized, F: FnMut(&Self::Item),
1.0.0 · source§fn collect<B>(self) -> Bwhere
B: FromIterator<Self::Item>,
Self: Sized,
fn collect<B>(self) -> Bwhere B: FromIterator<Self::Item>, Self: Sized,
source§fn collect_into<E>(self, collection: &mut E) -> &mut Ewhere
E: Extend<Self::Item>,
Self: Sized,
fn collect_into<E>(self, collection: &mut E) -> &mut Ewhere E: Extend<Self::Item>, Self: Sized,
iter_collect_into
#94780)1.0.0 · source§fn partition<B, F>(self, f: F) -> (B, B)where
Self: Sized,
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
fn partition<B, F>(self, f: F) -> (B, B)where Self: Sized, B: Default + Extend<Self::Item>, F: FnMut(&Self::Item) -> bool,
source§fn partition_in_place<'a, T, P>(self, predicate: P) -> usizewhere
T: 'a,
Self: Sized + DoubleEndedIterator<Item = &'a mut T>,
P: FnMut(&T) -> bool,
fn partition_in_place<'a, T, P>(self, predicate: P) -> usizewhere T: 'a, Self: Sized + DoubleEndedIterator<Item = &'a mut T>, P: FnMut(&T) -> bool,
iter_partition_in_place
#62543)source§fn is_partitioned<P>(self, predicate: P) -> boolwhere
Self: Sized,
P: FnMut(Self::Item) -> bool,
fn is_partitioned<P>(self, predicate: P) -> boolwhere Self: Sized, P: FnMut(Self::Item) -> bool,
iter_is_partitioned
#62544)1.27.0 · source§fn try_for_each<F, R>(&mut self, f: F) -> Rwhere
Self: Sized,
F: FnMut(Self::Item) -> R,
R: Try<Output = ()>,
fn try_for_each<F, R>(&mut self, f: F) -> Rwhere Self: Sized, F: FnMut(Self::Item) -> R, R: Try<Output = ()>,
1.51.0 · source§fn reduce<F>(self, f: F) -> Option<Self::Item>where
Self: Sized,
F: FnMut(Self::Item, Self::Item) -> Self::Item,
fn reduce<F>(self, f: F) -> Option<Self::Item>where Self: Sized, F: FnMut(Self::Item, Self::Item) -> Self::Item,
source§fn try_reduce<F, R>(
&mut self,
f: F
) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryTypewhere
Self: Sized,
F: FnMut(Self::Item, Self::Item) -> R,
R: Try<Output = Self::Item>,
<R as Try>::Residual: Residual<Option<Self::Item>>,
fn try_reduce<F, R>( &mut self, f: F ) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryTypewhere Self: Sized, F: FnMut(Self::Item, Self::Item) -> R, R: Try<Output = Self::Item>, <R as Try>::Residual: Residual<Option<Self::Item>>,
iterator_try_reduce
#87053)1.0.0 · source§fn all<F>(&mut self, f: F) -> boolwhere
Self: Sized,
F: FnMut(Self::Item) -> bool,
fn all<F>(&mut self, f: F) -> boolwhere Self: Sized, F: FnMut(Self::Item) -> bool,
1.0.0 · source§fn any<F>(&mut self, f: F) -> boolwhere
Self: Sized,
F: FnMut(Self::Item) -> bool,
fn any<F>(&mut self, f: F) -> boolwhere Self: Sized, F: FnMut(Self::Item) -> bool,
1.0.0 · source§fn find<P>(&mut self, predicate: P) -> Option<Self::Item>where
Self: Sized,
P: FnMut(&Self::Item) -> bool,
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>where Self: Sized, P: FnMut(&Self::Item) -> bool,
1.30.0 · source§fn find_map<B, F>(&mut self, f: F) -> Option<B>where
Self: Sized,
F: FnMut(Self::Item) -> Option<B>,
fn find_map<B, F>(&mut self, f: F) -> Option<B>where Self: Sized, F: FnMut(Self::Item) -> Option<B>,
source§fn try_find<F, R>(
&mut self,
f: F
) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryTypewhere
Self: Sized,
F: FnMut(&Self::Item) -> R,
R: Try<Output = bool>,
<R as Try>::Residual: Residual<Option<Self::Item>>,
fn try_find<F, R>( &mut self, f: F ) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryTypewhere Self: Sized, F: FnMut(&Self::Item) -> R, R: Try<Output = bool>, <R as Try>::Residual: Residual<Option<Self::Item>>,
try_find
#63178)1.0.0 · source§fn position<P>(&mut self, predicate: P) -> Option<usize>where
Self: Sized,
P: FnMut(Self::Item) -> bool,
fn position<P>(&mut self, predicate: P) -> Option<usize>where Self: Sized, P: FnMut(Self::Item) -> bool,
1.6.0 · source§fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>where
B: Ord,
Self: Sized,
F: FnMut(&Self::Item) -> B,
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>where B: Ord, Self: Sized, F: FnMut(&Self::Item) -> B,
1.15.0 · source§fn max_by<F>(self, compare: F) -> Option<Self::Item>where
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
fn max_by<F>(self, compare: F) -> Option<Self::Item>where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.6.0 · source§fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>where
B: Ord,
Self: Sized,
F: FnMut(&Self::Item) -> B,
fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>where B: Ord, Self: Sized, F: FnMut(&Self::Item) -> B,
1.15.0 · source§fn min_by<F>(self, compare: F) -> Option<Self::Item>where
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
fn min_by<F>(self, compare: F) -> Option<Self::Item>where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.0.0 · source§fn rev(self) -> Rev<Self> ⓘwhere
Self: Sized + DoubleEndedIterator,
fn rev(self) -> Rev<Self> ⓘwhere Self: Sized + DoubleEndedIterator,
1.0.0 · source§fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Sized + Iterator<Item = (A, B)>,
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)where FromA: Default + Extend<A>, FromB: Default + Extend<B>, Self: Sized + Iterator<Item = (A, B)>,
1.36.0 · source§fn copied<'a, T>(self) -> Copied<Self> ⓘwhere
T: 'a + Copy,
Self: Sized + Iterator<Item = &'a T>,
fn copied<'a, T>(self) -> Copied<Self> ⓘwhere T: 'a + Copy, Self: Sized + Iterator<Item = &'a T>,
1.0.0 · source§fn cloned<'a, T>(self) -> Cloned<Self> ⓘwhere
T: 'a + Clone,
Self: Sized + Iterator<Item = &'a T>,
fn cloned<'a, T>(self) -> Cloned<Self> ⓘwhere T: 'a + Clone, Self: Sized + Iterator<Item = &'a T>,
source§fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N> ⓘwhere
Self: Sized,
fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N> ⓘwhere Self: Sized,
iter_array_chunks
#100450)N
个元素的迭代器。 Read more1.11.0 · source§fn product<P>(self) -> Pwhere
Self: Sized,
P: Product<Self::Item>,
fn product<P>(self) -> Pwhere Self: Sized, P: Product<Self::Item>,
source§fn cmp_by<I, F>(self, other: I, cmp: F) -> Orderingwhere
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
fn cmp_by<I, F>(self, other: I, cmp: F) -> Orderingwhere Self: Sized, I: IntoIterator, F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
iter_order_by
#64295)1.5.0 · source§fn partial_cmp<I>(self, other: I) -> Option<Ordering>where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Self: Sized,
fn partial_cmp<I>(self, other: I) -> Option<Ordering>where I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,
Iterator
的 PartialOrd
元素与另一个 PartialOrd
的元素进行比较。
比较的工作方式类似于短路评估,返回结果而不比较其余元素。
一旦可以确定订单,评估就会停止并返回结果。 Read moresource§fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
iter_order_by
#64295)1.5.0 · source§fn eq<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
Self: Sized,
fn eq<I>(self, other: I) -> boolwhere I: IntoIterator, Self::Item: PartialEq<<I as IntoIterator>::Item>, Self: Sized,
source§fn eq_by<I, F>(self, other: I, eq: F) -> boolwhere
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
fn eq_by<I, F>(self, other: I, eq: F) -> boolwhere Self: Sized, I: IntoIterator, F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
iter_order_by
#64295)1.5.0 · source§fn ne<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
Self: Sized,
fn ne<I>(self, other: I) -> boolwhere I: IntoIterator, Self::Item: PartialEq<<I as IntoIterator>::Item>, Self: Sized,
1.5.0 · source§fn lt<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Self: Sized,
fn lt<I>(self, other: I) -> boolwhere I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,
1.5.0 · source§fn le<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Self: Sized,
fn le<I>(self, other: I) -> boolwhere I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,
1.5.0 · source§fn gt<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Self: Sized,
fn gt<I>(self, other: I) -> boolwhere I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,
1.5.0 · source§fn ge<I>(self, other: I) -> boolwhere
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Self: Sized,
fn ge<I>(self, other: I) -> boolwhere I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,
source§fn is_sorted_by<F>(self, compare: F) -> boolwhere
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
fn is_sorted_by<F>(self, compare: F) -> boolwhere Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
is_sorted
#53485)source§fn is_sorted_by_key<F, K>(self, f: F) -> boolwhere
Self: Sized,
F: FnMut(Self::Item) -> K,
K: PartialOrd<K>,
fn is_sorted_by_key<F, K>(self, f: F) -> boolwhere Self: Sized, F: FnMut(Self::Item) -> K, K: PartialOrd<K>,
is_sorted
#53485)source§impl<Idx> PartialEq<RangeInclusive<Idx>> for RangeInclusive<Idx>where
Idx: PartialEq<Idx>,
impl<Idx> PartialEq<RangeInclusive<Idx>> for RangeInclusive<Idx>where Idx: PartialEq<Idx>,
1.28.0 · source§impl<T> RangeBounds<T> for RangeInclusive<&T>
impl<T> RangeBounds<T> for RangeInclusive<&T>
1.28.0 · source§impl<T> RangeBounds<T> for RangeInclusive<T>
impl<T> RangeBounds<T> for RangeInclusive<T>
const: unstable · source§impl<T> SliceIndex<[T]> for RangeInclusive<usize>
impl<T> SliceIndex<[T]> for RangeInclusive<usize>
const: unstable · source§fn get(self, slice: &[T]) -> Option<&[T]>
fn get(self, slice: &[T]) -> Option<&[T]>
slice_index_methods
)const: unstable · source§fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
slice_index_methods
)const: unstable · source§unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
slice_index_methods
)slice
指针调用此方法也是 [undefined 行为]。const: unstable · source§unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
slice_index_methods
)slice
指针调用此方法也是 [undefined 行为]。const: unstable · source§impl SliceIndex<str> for RangeInclusive<usize>
impl SliceIndex<str> for RangeInclusive<usize>
使用语法 &self[begin ..= end]
或 &mut self[begin ..= end]
实现子字符串切片。
从字节范围 [begin
, end
] 返回给定字符串的切片。等效于 &self [begin .. end + 1]
或 &mut self[begin .. end + 1]
,除非 end
具有 usize
的最大值。
此运算为 O(1)。
Panics
如果 begin
没有指向字符的起始字节偏移量 (由 is_char_boundary
定义),如果 end
没有指向字符的结束字节偏移量 (end + 1
是起始字节偏移量或等于 len
),如果 begin > end
,或者如果 end >= len
,就会出现 panics。
const: unstable · source§fn get(
self,
slice: &str
) -> Option<&<RangeInclusive<usize> as SliceIndex<str>>::Output>
fn get( self, slice: &str ) -> Option<&<RangeInclusive<usize> as SliceIndex<str>>::Output>
slice_index_methods
)const: unstable · source§fn get_mut(
self,
slice: &mut str
) -> Option<&mut <RangeInclusive<usize> as SliceIndex<str>>::Output>
fn get_mut( self, slice: &mut str ) -> Option<&mut <RangeInclusive<usize> as SliceIndex<str>>::Output>
slice_index_methods
)const: unstable · source§unsafe fn get_unchecked(
self,
slice: *const str
) -> *const <RangeInclusive<usize> as SliceIndex<str>>::Output
unsafe fn get_unchecked( self, slice: *const str ) -> *const <RangeInclusive<usize> as SliceIndex<str>>::Output
slice_index_methods
)slice
指针调用此方法也是 [undefined 行为]。const: unstable · source§unsafe fn get_unchecked_mut(
self,
slice: *mut str
) -> *mut <RangeInclusive<usize> as SliceIndex<str>>::Output
unsafe fn get_unchecked_mut( self, slice: *mut str ) -> *mut <RangeInclusive<usize> as SliceIndex<str>>::Output
slice_index_methods
)slice
指针调用此方法也是 [undefined 行为]。const: unstable · source§fn index(
self,
slice: &str
) -> &<RangeInclusive<usize> as SliceIndex<str>>::Output ⓘ
fn index( self, slice: &str ) -> &<RangeInclusive<usize> as SliceIndex<str>>::Output ⓘ
slice_index_methods
)const: unstable · source§fn index_mut(
self,
slice: &mut str
) -> &mut <RangeInclusive<usize> as SliceIndex<str>>::Output ⓘ
fn index_mut( self, slice: &mut str ) -> &mut <RangeInclusive<usize> as SliceIndex<str>>::Output ⓘ
slice_index_methods
)