Struct std::str::SplitInclusive

1.51.0 · source ·
pub struct SplitInclusive<'a, P>(_)
where
         P: Pattern<'a>;
Expand description

字符串子字符串上的迭代器,由与谓词函数匹配的子字符串终止,与 Split 不同,它包含匹配的部分作为子切片的终止符。

该结构体是通过 str 上的 split_inclusive 方法创建的。 有关更多信息,请参见其文档。

Implementations§

source§

impl<'a, P> SplitInclusive<'a, P>where P: Pattern<'a>,

source

pub fn remainder(&self) -> Option<&'a str>

🔬This is a nightly-only experimental API. (str_split_inclusive_remainder #77998)

返回分割字符串的剩余部分。

如果迭代器为空,则返回 None

Examples
#![feature(str_split_inclusive_remainder)]
let mut split = "Mary had a little lamb".split_inclusive(' ');
assert_eq!(split.remainder(), Some("Mary had a little lamb"));
split.next();
assert_eq!(split.remainder(), Some("had a little lamb"));
split.by_ref().for_each(drop);
assert_eq!(split.remainder(), None);
Run

Trait Implementations§

source§

impl<'a, P> Clone for SplitInclusive<'a, P>where P: Pattern<'a>, <P as Pattern<'a>>::Searcher: Clone,

source§

fn clone(&self) -> SplitInclusive<'a, P>

返回值的副本。 Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

source 执行复制分配。 Read more
source§

impl<'a, P> Debug for SplitInclusive<'a, P>where P: Pattern<'a>, <P as Pattern<'a>>::Searcher: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

使用给定的格式化程序格式化该值。 Read more
source§

impl<'a, P> DoubleEndedIterator for SplitInclusive<'a, P>where P: Pattern<'a>, <P as Pattern<'a>>::Searcher: ReverseSearcher<'a>,

source§

fn next_back(&mut self) -> Option<&'a str>

从迭代器的末尾删除并返回一个元素。 Read more
source§

fn advance_back_by(&mut self, n: usize) -> Result<(), NonZeroUsize>

🔬This is a nightly-only experimental API. (iter_advance_by #77404)
通过 n 元素从后向前推进迭代器。 Read more
1.37.0 · source§

fn nth_back(&mut self, n: usize) -> Option<Self::Item>

从迭代器的末尾返回第 n 个元素。 Read more
1.27.0 · source§

fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> Rwhere Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Output = B>,

这是 Iterator::try_fold() 的反向版本:它从迭代器的后面开始接收元素。 Read more
1.27.0 · source§

fn rfold<B, F>(self, init: B, f: F) -> Bwhere Self: Sized, F: FnMut(B, Self::Item) -> B,

一种迭代器方法,从后面开始,将迭代器的元素减少为单个最终值。 Read more
1.27.0 · source§

fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item>where Self: Sized, P: FnMut(&Self::Item) -> bool,

从后面搜索满足谓词的迭代器的元素。 Read more
source§

impl<'a, P> Iterator for SplitInclusive<'a, P>where P: Pattern<'a>,

§

type Item = &'a str

被迭代的元素的类型。
source§

fn next(&mut self) -> Option<&'a str>

推进迭代器并返回下一个值。 Read more
source§

fn next_chunk<const N: usize>( &mut self ) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where Self: Sized,

🔬This is a nightly-only experimental API. (iter_next_chunk #98326)
推进迭代器并返回包含下一个 N 值的数组。 Read more
1.0.0 · source§

fn size_hint(&self) -> (usize, Option<usize>)

返回迭代器剩余长度的界限。 Read more
1.0.0 · source§

fn count(self) -> usizewhere Self: Sized,

消耗迭代器,计算迭代次数并返回它。 Read more
1.0.0 · source§

fn last(self) -> Option<Self::Item>where Self: Sized,

消耗迭代器,返回最后一个元素。 Read more
source§

fn advance_by(&mut self, n: usize) -> Result<(), NonZeroUsize>

🔬This is a nightly-only experimental API. (iter_advance_by #77404)
通过 n 元素使迭代器前进。 Read more
1.0.0 · source§

fn nth(&mut self, n: usize) -> Option<Self::Item>

返回迭代器的第 n 个元素。 Read more
1.28.0 · source§

fn step_by(self, step: usize) -> StepBy<Self> where Self: Sized,

创建一个从同一点开始的迭代器,但在每次迭代时以给定的数量逐步执行。 Read more
1.0.0 · source§

fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where Self: Sized, U: IntoIterator<Item = Self::Item>,

接受两个迭代器,并依次在两个迭代器上创建一个新的迭代器。 Read more
1.0.0 · source§

fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where Self: Sized, U: IntoIterator,

将两个迭代器压缩为成对的单个迭代器。 Read more
source§

fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G> where Self: Sized, G: FnMut() -> Self::Item,

🔬This is a nightly-only experimental API. (iter_intersperse #79524)
创建一个新的迭代器,该迭代器将 separator 生成的项放在原始迭代器的相邻项之间。 Read more
1.0.0 · source§

fn map<B, F>(self, f: F) -> Map<Self, F> where Self: Sized, F: FnMut(Self::Item) -> B,

获取一个闭包并创建一个迭代器,该迭代器在每个元素上调用该闭包。 Read more
1.21.0 · source§

fn for_each<F>(self, f: F)where Self: Sized, F: FnMut(Self::Item),

在迭代器的每个元素上调用一个闭包。 Read more
1.0.0 · source§

fn filter<P>(self, predicate: P) -> Filter<Self, P> where Self: Sized, P: FnMut(&Self::Item) -> bool,

创建一个迭代器,该迭代器使用闭包确定是否应产生元素。 Read more
1.0.0 · source§

fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where Self: Sized, F: FnMut(Self::Item) -> Option<B>,

创建一个同时过滤和映射的迭代器。 Read more
1.0.0 · source§

fn enumerate(self) -> Enumerate<Self> where Self: Sized,

创建一个迭代器,该迭代器给出当前迭代次数以及下一个值。 Read more
1.0.0 · source§

fn peekable(self) -> Peekable<Self> where Self: Sized,

创建一个迭代器,它可以使用 peekpeek_mut 方法查看迭代器的下一个元素而不消耗它。有关更多信息,请参见他们的文档。 Read more
1.0.0 · source§

fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where Self: Sized, P: FnMut(&Self::Item) -> bool,

创建一个迭代器,该迭代器基于谓词 skip 元素。 Read more
1.0.0 · source§

fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where Self: Sized, P: FnMut(&Self::Item) -> bool,

创建一个迭代器,该迭代器根据谓词产生元素。 Read more
1.57.0 · source§

fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> where Self: Sized, P: FnMut(Self::Item) -> Option<B>,

创建一个迭代器,该迭代器均基于谓词和映射生成元素。 Read more
1.0.0 · source§

fn skip(self, n: usize) -> Skip<Self> where Self: Sized,

创建一个跳过前 n 个元素的迭代器。 Read more
1.0.0 · source§

fn take(self, n: usize) -> Take<Self> where Self: Sized,

创建一个迭代器,它产生第一个 n 元素,如果底层迭代器提前结束,则产生更少的元素。 Read more
1.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>,

一个迭代器适配器,它与 fold 一样保存内部状态,但与 fold 不同,它生成一个新的迭代器。 Read more
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,

创建一个迭代器,其工作方式类似于 map,但它会将嵌套的结构展平。 Read more
1.0.0 · source§

fn fuse(self) -> Fuse<Self> where Self: Sized,

创建一个迭代器,该迭代器在第一个 None 之后结束。 Read more
1.0.0 · source§

fn inspect<F>(self, f: F) -> Inspect<Self, F> where Self: Sized, F: FnMut(&Self::Item),

对迭代器的每个元素执行某些操作,将值传递给它。 Read more
1.0.0 · source§

fn by_ref(&mut self) -> &mut Selfwhere Self: Sized,

借用一个迭代器,而不是使用它。 Read more
1.0.0 · source§

fn collect<B>(self) -> Bwhere B: FromIterator<Self::Item>, Self: Sized,

将迭代器转换为集合。 Read more
source§

fn collect_into<E>(self, collection: &mut E) -> &mut Ewhere E: Extend<Self::Item>, Self: Sized,

🔬This is a nightly-only experimental API. (iter_collect_into #94780)
将迭代器中的所有项收集到一个集合中。 Read more
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,

消耗一个迭代器,从中创建两个集合。 Read more
source§

fn is_partitioned<P>(self, predicate: P) -> boolwhere Self: Sized, P: FnMut(Self::Item) -> bool,

🔬This is a nightly-only experimental API. (iter_is_partitioned #62544)
检查此迭代器的元素是否根据给定的谓词进行了分区,以便所有返回 true 的元素都在所有返回 false 的元素之前。 Read more
1.27.0 · source§

fn try_fold<B, F, R>(&mut self, init: B, f: F) -> Rwhere Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Output = B>,

一个迭代器方法,它只要成功返回就应用函数,并产生单个最终值。 Read more
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 = ()>,

一个迭代器方法,该方法将一个容易犯错的函数应用于迭代器中的每个项,在第一个错误处停止并返回该错误。 Read more
1.0.0 · source§

fn fold<B, F>(self, init: B, f: F) -> Bwhere Self: Sized, F: FnMut(B, Self::Item) -> B,

通过应用操作将每个元素 fold 到一个累加器中,返回最终结果。 Read more
source§

fn reduce<F>(self, f: F) -> Option<Self::Item>where Self: Sized, F: FnMut(Self::Item, Self::Item) -> Self::Item,

通过重复应用缩减操作,将元素缩减为一个。 Read more
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>>,

🔬This is a nightly-only experimental API. (iterator_try_reduce #87053)
通过重复应用 Reduce 操作,将元素归约为单个元素。 如果闭包返回失败,则失败会立即传播给调用者。 Read more
1.0.0 · source§

fn all<F>(&mut self, f: F) -> boolwhere Self: Sized, F: FnMut(Self::Item) -> bool,

测试迭代器的每个元素是否与谓词匹配。 Read more
1.0.0 · source§

fn any<F>(&mut self, f: F) -> boolwhere Self: Sized, F: FnMut(Self::Item) -> bool,

测试迭代器的任何元素是否与谓词匹配。 Read more
1.0.0 · source§

fn find<P>(&mut self, predicate: P) -> Option<Self::Item>where Self: Sized, P: FnMut(&Self::Item) -> bool,

搜索满足谓词的迭代器的元素。 Read more
1.30.0 · source§

fn find_map<B, F>(&mut self, f: F) -> Option<B>where Self: Sized, F: FnMut(Self::Item) -> Option<B>,

将函数应用于迭代器的元素,并返回第一个非 None 的结果。 Read more
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>>,

🔬This is a nightly-only experimental API. (try_find #63178)
将函数应用于迭代器的元素,并返回第一个为 true 的结果或第一个错误。 Read more
1.0.0 · source§

fn position<P>(&mut self, predicate: P) -> Option<usize>where Self: Sized, P: FnMut(Self::Item) -> bool,

在迭代器中搜索元素,并返回其索引。 Read more
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,

返回给出指定函数最大值的元素。 Read more
1.15.0 · source§

fn max_by<F>(self, compare: F) -> Option<Self::Item>where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering,

返回给出相对于指定比较函数的最大值的元素。 Read more
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,

返回给出指定函数中最小值的元素。 Read more
1.15.0 · source§

fn min_by<F>(self, compare: F) -> Option<Self::Item>where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering,

返回给出相对于指定比较函数的最小值的元素。 Read more
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)>,

将成对的迭代器转换为一对容器。 Read more
1.36.0 · source§

fn copied<'a, T>(self) -> Copied<Self> where T: 'a + Copy, Self: Sized + Iterator<Item = &'a T>,

创建一个迭代器,该迭代器将复制其所有元素。 Read more
1.0.0 · source§

fn cloned<'a, T>(self) -> Cloned<Self> where T: 'a + Clone, Self: Sized + Iterator<Item = &'a T>,

创建一个迭代器,该迭代器将克隆所有元素。 Read more
source§

fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N> where Self: Sized,

🔬This is a nightly-only experimental API. (iter_array_chunks #100450)
一次返回迭代器的 N 个元素的迭代器。 Read more
1.11.0 · source§

fn sum<S>(self) -> Swhere Self: Sized, S: Sum<Self::Item>,

对迭代器的元素求和。 Read more
1.11.0 · source§

fn product<P>(self) -> Pwhere Self: Sized, P: Product<Self::Item>,

遍历整个迭代器,将所有元素相乘 Read more
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,

🔬This is a nightly-only experimental API. (iter_order_by #64295)
字典顺序 根据指定的比较函数将这个 Iterator 的元素与另一个 Iterator 的元素进行比较。 Read more
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,

Lexicographically 将此 IteratorPartialOrd 元素与另一个 PartialOrd 的元素进行比较。 比较的工作方式类似于短路评估,返回结果而不比较其余元素。 一旦可以确定订单,评估就会停止并返回结果。 Read more
source§

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>,

🔬This is a nightly-only experimental API. (iter_order_by #64295)
字典顺序 根据指定的比较函数将这个 Iterator 的元素与另一个 Iterator 的元素进行比较。 Read more
1.5.0 · source§

fn eq<I>(self, other: I) -> boolwhere I: IntoIterator, Self::Item: PartialEq<<I as IntoIterator>::Item>, Self: Sized,

确定此 Iterator 的元素是否与另一个元素相同。 Read more
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,

🔬This is a nightly-only experimental API. (iter_order_by #64295)
关于指定的相等函数,确定 Iterator 的元素是否与另一个元素相等。 Read more
1.5.0 · source§

fn ne<I>(self, other: I) -> boolwhere I: IntoIterator, Self::Item: PartialEq<<I as IntoIterator>::Item>, Self: Sized,

确定此 Iterator 的元素是否不等于另一个的元素。 Read more
1.5.0 · source§

fn lt<I>(self, other: I) -> boolwhere I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

确定此 Iterator 的元素是否比另一个元素少 按字典顺序Read more
1.5.0 · source§

fn le<I>(self, other: I) -> boolwhere I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

确定此 Iterator 的元素是否 按字典顺序 小于或等于另一个元素。 Read more
1.5.0 · source§

fn gt<I>(self, other: I) -> boolwhere I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

确定此 Iterator 的元素是否大于另一个元素的 按字典顺序Read more
1.5.0 · source§

fn ge<I>(self, other: I) -> boolwhere I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

确定此 Iterator 的元素是否 按字典顺序 大于或等于另一个元素。 Read more
source§

fn is_sorted_by<F>(self, compare: F) -> boolwhere Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,

🔬This is a nightly-only experimental API. (is_sorted #53485)
检查此迭代器的元素是否使用给定的比较器函数进行排序。 Read more
source§

fn is_sorted_by_key<F, K>(self, f: F) -> boolwhere Self: Sized, F: FnMut(Self::Item) -> K, K: PartialOrd<K>,

🔬This is a nightly-only experimental API. (is_sorted #53485)
检查此迭代器的元素是否使用给定的键提取函数进行排序。 Read more
source§

impl<'a, P> FusedIterator for SplitInclusive<'a, P>where P: Pattern<'a>,

Auto Trait Implementations§

§

impl<'a, P> RefUnwindSafe for SplitInclusive<'a, P>where <P as Pattern<'a>>::Searcher: RefUnwindSafe,

§

impl<'a, P> Send for SplitInclusive<'a, P>where <P as Pattern<'a>>::Searcher: Send,

§

impl<'a, P> Sync for SplitInclusive<'a, P>where <P as Pattern<'a>>::Searcher: Sync,

§

impl<'a, P> Unpin for SplitInclusive<'a, P>where <P as Pattern<'a>>::Searcher: Unpin,

§

impl<'a, P> UnwindSafe for SplitInclusive<'a, P>where <P as Pattern<'a>>::Searcher: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

获取 selfTypeIdRead more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

从拥有的值中一成不变地借用。 Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

从拥有的值中借用。 Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

返回未更改的参数。

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

调用 U::from(self)

也就是说,这种转换是 From<T> for U 实现选择执行的任何操作。

source§

impl<I> IntoIterator for Iwhere I: Iterator,

§

type Item = <I as Iterator>::Item

被迭代的元素的类型。
§

type IntoIter = I

我们将其变成哪种迭代器?
const: unstable · source§

fn into_iter(self) -> I

从一个值创建一个迭代器。 Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

获得所有权后的结果类型。
source§

fn to_owned(&self) -> T

从借用的数据创建拥有的数据,通常是通过克隆。 Read more
source§

fn clone_into(&self, target: &mut T)

使用借来的数据来替换拥有的数据,通常是通过克隆。 Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

发生转换错误时返回的类型。
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

执行转换。
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

发生转换错误时返回的类型。
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

执行转换。