结构体 IntoIter

从 Rust 1.29.0 版本开始稳定 · 源代码
pub struct IntoIter(/* private fields */);
展开描述

一个遍历 TokenStreamTokenTrees 的迭代器。迭代是“浅层”的,例如,迭代器不会递归进入分隔的组,而是将整个组作为 token tree 返回。

特性实现§

从 Rust 1.29.0 版本开始稳定 · 源代码§

impl Clone for IntoIter

源代码§

fn clone(&self) -> IntoIter

返回值的副本。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

source 执行复制赋值。 阅读更多
从 Rust 1.29.0 版本开始稳定 · 源代码§

impl Iterator for IntoIter

源代码§

type Item = TokenTree

迭代元素的类型。
源代码§

fn next(&mut self) -> Option<TokenTree>

推进迭代器并返回下一个值。 阅读更多
源代码§

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

返回迭代器剩余长度的界限。 阅读更多
源代码§

fn count(self) -> usize

消耗迭代器,计算迭代次数并返回。 阅读更多
源代码§

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

🔬这是一个仅限 Nightly 版本的实验性 API。(iter_next_chunk #98326)
推进迭代器并返回包含接下来的 N 个值的数组。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

消耗迭代器,返回最后一个元素。 阅读更多
源代码§

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

🔬这是一个仅限 Nightly 版本的实验性 API。(iter_advance_by #77404)
将迭代器向前推进 n 个元素。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

返回迭代器的第 n 个元素。 阅读更多
从 Rust 1.28.0 版本开始稳定 · 源代码§

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

创建一个从同一点开始,但在每次迭代时按给定步长前进的迭代器。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

接收两个迭代器,并创建一个按顺序遍历两者的迭代器。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

将两个迭代器“压缩”成一个包含对的迭代器。 阅读更多
源代码§

fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
where Self: Sized, Self::Item: Clone,

🔬这是一个仅限 Nightly 版本的实验性 API。(iter_intersperse #79524)
创建一个新的迭代器,它在原始迭代器的相邻项之间放置 separator 的副本。 阅读更多
源代码§

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

🔬这是一个仅限 Nightly 版本的实验性 API。(iter_intersperse #79524)
创建一个新的迭代器,它在原始迭代器的相邻项之间放置由 separator 生成的项。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

接受一个闭包,并创建一个迭代器,该迭代器在每个元素上调用该闭包。 阅读更多
从 Rust 1.21.0 版本开始稳定 · 源代码§

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

对迭代器的每个元素调用一个闭包。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

创建一个使用闭包来确定是否应生成元素的迭代器。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

创建一个既过滤又映射的迭代器。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

创建一个提供当前迭代计数以及下一个值的迭代器。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

创建一个可以使用 peekpeek_mut 方法查看迭代器下一个元素而不消耗它的迭代器。有关更多信息,请参阅它们的文档。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

创建一个根据谓词跳过元素的迭代器。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

创建一个根据谓词生成元素的迭代器。 阅读更多
从 Rust 1.57.0 版本开始稳定 · 源代码§

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

创建一个既根据谓词生成元素又进行映射的迭代器。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

创建一个跳过前 n 个元素的迭代器。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

创建一个生成前 n 个元素的迭代器,如果底层迭代器提前结束,则生成少于 n 个元素。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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 不同的是,它生成一个新的迭代器。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
where Self: Sized, U: IntoIterator, F: FnMut(Self::Item) -> U,

创建一个像 map 一样工作但会展平嵌套结构的迭代器。 阅读更多
源代码§

fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>
where Self: Sized, F: FnMut(&[Self::Item; N]) -> R,

🔬这是一个仅限 Nightly 版本的实验性 API。(iter_map_windows #87155)
对于 `self` 上大小为 `N` 的每个连续窗口,调用给定函数 `f`,并返回一个遍历 `f` 输出的迭代器。与 slice::windows() 一样,映射过程中的窗口也会重叠。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

创建一个在遇到第一个 None 后结束的迭代器。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

对迭代器的每个元素执行某种操作,并将值传递下去。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

为该 Iterator 实例创建一个“按引用”适配器。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

将迭代器转换为集合。 阅读更多
源代码§

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

🔬这是一个仅限 Nightly 版本的实验性 API。(iter_collect_into #94780)
将迭代器中的所有项收集到集合中。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

fn partition<B, F>(self, f: F) -> (B, B)
where Self: Sized, B: Default + Extend<Self::Item>, F: FnMut(&Self::Item) -> bool,

消耗一个迭代器,并从中创建两个集合。 阅读更多
源代码§

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

🔬这是一个仅限 Nightly 版本的实验性 API。(iter_is_partitioned #62544)
检查此迭代器的元素是否根据给定谓词进行了划分,使得所有返回 true 的元素都在所有返回 false 的元素之前。 阅读更多
从 Rust 1.27.0 版本开始稳定 · 源代码§

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

一个迭代器方法,只要函数成功返回,就应用该函数,产生一个单一的最终值。 阅读更多
从 Rust 1.27.0 版本开始稳定 · 源代码§

fn try_for_each<F, R>(&mut self, f: F) -> R
where Self: Sized, F: FnMut(Self::Item) -> R, R: Try<Output = ()>,

一个迭代器方法,对迭代器中的每个项应用一个可能失败的函数,并在遇到第一个错误时停止并返回该错误。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

通过应用一个操作将每个元素折叠到一个累加器中,返回最终结果。 阅读更多
从 Rust 1.51.0 版本开始稳定 · 源代码§

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

通过重复应用归约操作,将元素归约为单个值。 阅读更多
源代码§

fn try_reduce<R>( &mut self, f: impl FnMut(Self::Item, Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType
where Self: Sized, R: Try<Output = Self::Item>, <R as Try>::Residual: Residual<Option<Self::Item>>,

🔬这是一个仅限 Nightly 版本的实验性 API。(iterator_try_reduce #87053)
通过重复应用归约操作,将元素归约为单个值。如果闭包返回失败,则该失败会立即传播回调用者。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

测试迭代器的每个元素是否都匹配一个谓词。 阅读更多
从 Rust 1.0.0 版本开始稳定 · 源代码§

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

where Self: Sized, F: FnMut(Self::Item) -> bool,
测试迭代器的任一元素是否匹配一个谓词。 阅读更多

从 Rust 1.0.0 版本开始稳定 · 源代码§
where Self: Sized, P: FnMut(&Self::Item) -> bool,

fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
搜索迭代器中满足谓词的元素。 阅读更多

从 Rust 1.30.0 版本开始稳定 · 源代码§
where Self: Sized, F: FnMut(Self::Item) -> Option<B>,

fn find_map<B, F>(&mut self, f: F) -> Option<B>
将函数应用于迭代器的元素,并返回第一个非 None 结果。 阅读更多

源代码§
fn try_find<R>( &mut self, f: impl FnMut(&Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType

where Self: Sized, R: Try<Output = bool>, <R as Try>::Residual: Residual<Option<Self::Item>>,
🔬这是一个仅限 Nightly 版本的实验性 API。(try_find #63178)
将函数应用于迭代器的元素,并返回第一个 true 结果或第一个错误。 阅读更多

从 Rust 1.0.0 版本开始稳定 · 源代码§
where Self: Sized, P: FnMut(Self::Item) -> bool,

fn position<P>(&mut self, predicate: P) -> Option<usize>
在迭代器中搜索元素,返回其索引。 阅读更多

从 Rust 1.6.0 版本开始稳定 · 源代码§
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>

where B: Ord, Self: Sized, F: FnMut(&Self::Item) -> B,
返回根据指定函数产生最大值的元素。 阅读更多

从 Rust 1.15.0 版本开始稳定 · 源代码§
fn max_by<F>(self, compare: F) -> Option<Self::Item>

where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering,
返回根据指定比较函数产生最大值的元素。 阅读更多

从 Rust 1.6.0 版本开始稳定 · 源代码§
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>

fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
返回根据指定函数产生最小值的元素。 阅读更多

从 Rust 1.15.0 版本开始稳定 · 源代码§
fn max_by<F>(self, compare: F) -> Option<Self::Item>

fn min_by<F>(self, compare: F) -> Option<Self::Item>
返回根据指定比较函数产生最小值的元素。 阅读更多

从 Rust 1.0.0 版本开始稳定 · 源代码§
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)

where FromA: Default + Extend<A>, FromB: Default + Extend<B>, Self: Sized + Iterator<Item = (A, B)>,
将包含对的迭代器转换为一对容器。 阅读更多

从 Rust 1.36.0 版本开始稳定 · 源代码§
fn copied<'a, T>(self) -> Copied<Self>

where T: 'a + Copy, Self: Sized + Iterator<Item = &'a T>,
创建一个复制所有元素的迭代器。 阅读更多

从 Rust 1.0.0 版本开始稳定 · 源代码§
fn cloned<'a, T>(self) -> Cloned<Self>

where T: 'a + Clone, Self: Sized + Iterator<Item = &'a T>,
创建一个 clone 所有元素的迭代器。 阅读更多

从 Rust 1.0.0 版本开始稳定 · 源代码§
fn cycle(self) -> Cycle<Self>

where Self: Sized + Clone,
无限重复迭代器。 阅读更多

源代码§
where Self: Sized,

fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>
🔬这是一个仅限 Nightly 版本的实验性 API。(iter_array_chunks #100450)
一次返回迭代器上 N 个元素的迭代器。 阅读更多

从 Rust 1.11.0 版本开始稳定 · 源代码§
fn sum<S>(self) -> S

where Self: Sized, S: Sum<Self::Item>,
对迭代器的元素求和。 阅读更多

从 Rust 1.11.0 版本开始稳定 · 源代码§
fn product<P>(self) -> P

where Self: Sized, P: Product<Self::Item>,
遍历整个迭代器,将所有元素相乘。 阅读更多

源代码§
fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering

where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
🔬这是一个仅限 Nightly 版本的实验性 API。(iter_order_by #64295)
相对于指定的比较函数,按 字典序 比较此 Iterator 的元素与另一个迭代器的元素。 阅读更多

从 Rust 1.5.0 版本开始稳定 · 源代码§
fn partial_cmp<I>(self, other: I) -> Option<Ordering>

where I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,
字典序 比较此 IteratorPartialOrd 元素与另一个迭代器的元素。比较方式类似于短路求值,无需比较剩余元素即可返回结果。一旦可以确定顺序,评估就会停止并返回结果。 阅读更多

源代码§
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) -> Ordering,
where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
相对于指定的比较函数,按 字典序 比较此 Iterator 的元素与另一个迭代器的元素。 阅读更多

从 Rust 1.5.0 版本开始稳定 · 源代码§
fn eq<I>(self, other: I) -> bool

where I: IntoIterator, Self::Item: PartialEq<<I as IntoIterator>::Item>, Self: Sized,
确定此 Iterator 的元素是否与另一个迭代器的元素相等。 阅读更多

源代码§
fn eq_by<I, F>(self, other: I, eq: F) -> bool

where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
相对于指定的相等函数,确定此 Iterator 的元素是否与另一个迭代器的元素相等。 阅读更多

从 Rust 1.5.0 版本开始稳定 · 源代码§
fn eq<I>(self, other: I) -> bool

fn ne<I>(self, other: I) -> bool
确定此 Iterator 的元素是否与另一个迭代器的元素不相等。 阅读更多

从 Rust 1.5.0 版本开始稳定 · 源代码§
fn partial_cmp<I>(self, other: I) -> Option<Ordering>

fn lt<I>(self, other: I) -> bool
确定此 Iterator 的元素是否按 字典序 小于另一个迭代器的元素。 阅读更多

从 Rust 1.5.0 版本开始稳定 · 源代码§
fn partial_cmp<I>(self, other: I) -> Option<Ordering>

fn le<I>(self, other: I) -> bool
确定此 Iterator 的元素是否按 字典序 小于或等于另一个迭代器的元素。 阅读更多

从 Rust 1.5.0 版本开始稳定 · 源代码§
fn partial_cmp<I>(self, other: I) -> Option<Ordering>

fn gt<I>(self, other: I) -> bool
确定此 Iterator 的元素是否按 字典序 大于另一个迭代器的元素。 阅读更多

从 Rust 1.5.0 版本开始稳定 · 源代码§
fn partial_cmp<I>(self, other: I) -> Option<Ordering>

fn ge<I>(self, other: I) -> bool
确定此 Iterator 的元素是否按 字典序 大于或等于另一个迭代器的元素。 阅读更多

从 Rust 1.82.0 版本开始稳定 · 源代码§
fn is_sorted_by<F>(self, compare: F) -> bool

where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> bool,
检查此迭代器的元素是否使用给定的比较函数进行排序。 阅读更多

从 Rust 1.82.0 版本开始稳定 · 源代码§
fn is_sorted_by_key<F, K>(self, f: F) -> bool

where Self: Sized, F: FnMut(Self::Item) -> K, K: PartialOrd,

检查此迭代器的元素是否使用给定的键提取函数进行排序。 阅读更多

impl UnwindSafe for IntoIter

覆盖实现§

源代码§
impl<T> Any for T

where T: 'static + ?Sized,

源代码§

fn type_id(&self) -> TypeId
获取 selfTypeId阅读更多

源代码§
impl<T> Borrow<T> for T

where T: ?Sized,

源代码§

fn borrow(&self) -> &T
从拥有值进行不可变借用。 阅读更多

源代码§
impl<T> Borrow<T> for T

impl<T> BorrowMut<T> for T

源代码§

fn borrow_mut(&mut self) -> &mut T
从拥有值进行可变借用。 阅读更多

源代码§
impl<T> CloneToUninit for T

where T: Clone,

源代码§

unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬这是一个仅限 Nightly 版本的实验性 API。(clone_to_uninit #126799)
self 执行复制赋值到 dest阅读更多

源代码§

impl<T> From<T> for T

源代码§

fn from(t: T) -> T

返回未更改的参数。

源代码§
impl<T, U> Into<U> for T

where U: From<T>,

源代码§

fn into(self) -> U

调用 U::from(self)

也就是说,此转换取决于 From<T> for U 的实现选择执行的操作。

源代码§
impl<I> IntoIterator for I

where I: Iterator,

源代码§

迭代元素的类型。
type Item = <I as Iterator>::Item

源代码§

type IntoIter = I
我们正在将其转换为哪种类型的迭代器?

源代码§

fn into_iter(self) -> I
从值创建迭代器。 阅读更多

源代码§
impl<T> CloneToUninit for T

impl<T> ToOwned for T

源代码§

type Owned = T
获取所有权后的结果类型。

源代码§

fn to_owned(&self) -> T
从借用数据创建拥有数据,通常通过克隆实现。 阅读更多

源代码§

fn clone_into(&self, target: &mut T)
使用借用数据替换拥有数据,通常通过克隆实现。 阅读更多

源代码§
impl<T, U> TryFrom<U> for T

where U: Into<T>,

源代码§

转换错误时返回的类型。

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

执行转换。
源代码§

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

源代码§

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

源代码§

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

执行转换。