]>
git.proxmox.com Git - rustc.git/blob - library/core/src/iter/adapters/by_ref_sized.rs
0b5e2a89ef3dedfe43fd6f6b95e638ba14ecb3cd
3 /// Like `Iterator::by_ref`, but requiring `Sized` so it can forward generics.
5 /// Ideally this will no longer be required, eventually, but as can be seen in
6 /// the benchmarks (as of Feb 2022 at least) `by_ref` can have performance cost.
7 pub(crate) struct ByRefSized
<'a
, I
>(pub &'a
mut I
);
9 impl<I
: Iterator
> Iterator
for ByRefSized
<'_
, I
> {
12 fn next(&mut self) -> Option
<Self::Item
> {
16 fn size_hint(&self) -> (usize, Option
<usize>) {
20 fn advance_by(&mut self, n
: usize) -> Result
<(), usize> {
24 fn nth(&mut self, n
: usize) -> Option
<Self::Item
> {
28 fn fold
<B
, F
>(self, init
: B
, f
: F
) -> B
30 F
: FnMut(B
, Self::Item
) -> B
,
35 fn try_fold
<B
, F
, R
>(&mut self, init
: B
, f
: F
) -> R
37 F
: FnMut(B
, Self::Item
) -> R
,
40 self.0.try_fold(init
, f
)