Debian Codegraph @

debian/missing-sources/itertools/src/pad_tail.rs

raw symbols SCIP
1 use craterust-analyzer cargo itertools 0.14.0 crate/::size_hintrust-analyzer cargo itertools 0.14.0 size_hint/;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::{Fuserust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/fuse/Fuse#, FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator#};
3
4 /// An iterator adaptor that pads a sequence to a minimum length by filling
5 /// missing elements using a closure.
6 ///
7 /// Iterator element type is `I::Item`.
8 ///
9 /// See [`.pad_using()`](crate::Itertools::pad_using) for more information.
10 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
11 #[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
12 pub struct PadUsingrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#<I, F> {
13 iterrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#iter.: Fuserust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/fuse/Fuse#<I>,
14 minrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#min.: usize,
15 posrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#pos.: usize,
16 fillerrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#filler.: F,
17 }
18
19 impl<I, F> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for PadUsingrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#<I, F>
20 where
21 I: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#,
22 {
23 debug_fmt_fieldsrust-analyzer cargo itertools 0.14.0 impl_macros/debug_fmt_fields!!(PadUsing, iterrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#iter., minrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#min., posrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#pos.);
24 }
25
26 /// Create a new `PadUsing` iterator.
27 pub fn pad_usingrust-analyzer cargo itertools 0.14.0 pad_tail/pad_using().<I, F>(iter: I, min: usize, filler: F) -> PadUsingrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#<I, F>
28 where
29 I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#,
30 F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(usize) -> I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#,
31 {
32 PadUsingrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing# {
33 iterrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#iter.: iter.fuserust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#fuse().(),
34 minrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#min.,
35 posrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#pos.: 0,
36 fillerrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#filler.,
37 }
38 }
39
40 impl<I, F> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for PadUsingrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#<I, F>
41 where
42 I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#,
43 F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(usize) -> I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#,
44 {
45 type Itemrust-analyzer cargo itertools 0.14.0 pad_tail/impl#[`PadUsing<I, F>`][Iterator]Item# = I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#;
46
47 #[inline]
48 fn nextrust-analyzer cargo itertools 0.14.0 pad_tail/impl#[`PadUsing<I, F>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo itertools 0.14.0 pad_tail/impl#[`PadUsing<I, F>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
49 match self.iterrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#iter..nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/fuse/impl#[`Fuse<I>`][Iterator]next().() {
50 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
51 if self.posrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().self.minrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#min. {
52 let e = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((self.fillerrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#filler.)(self.posrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#pos.));
53 self.posrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
54 e
55 } else {
56 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
57 }
58 }
59 e => {
60 self.posrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
61 e
62 }
63 }
64 }
65
66 fn size_hintrust-analyzer cargo itertools 0.14.0 pad_tail/impl#[`PadUsing<I, F>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) {
67 let tail = self.minrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#min..saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(self.posrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#pos.);
68 size_hintrust-analyzer cargo itertools 0.14.0 size_hint/::maxrust-analyzer cargo itertools 0.14.0 size_hint/max().(self.iterrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#iter..size_hintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/fuse/impl#[`Fuse<I>`][Iterator]size_hint().(), (tail, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(tail)))
69 }
70
71 fn foldrust-analyzer cargo itertools 0.14.0 pad_tail/impl#[`PadUsing<I, F>`][Iterator]fold().<B, G>(self, mut init: B, mut f: G) -> B
72 where
73 G: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(B, Selfrust-analyzer cargo itertools 0.14.0 pad_tail/impl#[`PadUsing<I, F>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#) -> B,
74 {
75 let mut pos = self.posrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#pos.;
76 init = self.iterrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#iter..foldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/fuse/impl#[`Fuse<I>`][Iterator]fold().(init, |acc, item| {
77 pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
78 f(acc, item)
79 });
80 (pos..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.minrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#min.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(self.fillerrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#filler.).foldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]fold().(init, f)
81 }
82 }
83
84 impl<I, F> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for PadUsingrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#<I, F>
85 where
86 I: DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# + ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator#,
87 F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(usize) -> I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#,
88 {
89 fn next_backrust-analyzer cargo itertools 0.14.0 pad_tail/impl#[`PadUsing<I, F>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo itertools 0.14.0 pad_tail/impl#[`PadUsing<I, F>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
90 if self.minrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#min. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
91 self.iterrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#iter..next_backrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/fuse/impl#[`Fuse<I>`][DoubleEndedIterator]next_back().()
92 } else if self.iterrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#iter..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/fuse/impl#[`Fuse<I>`][ExactSizeIterator]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().self.minrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#min. {
93 self.minrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#min. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1;
94 self.iterrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#iter..next_backrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/fuse/impl#[`Fuse<I>`][DoubleEndedIterator]next_back().()
95 } else {
96 self.minrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#min. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1;
97 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((self.fillerrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#filler.)(self.minrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#min.))
98 }
99 }
100
101 fn rfoldrust-analyzer cargo itertools 0.14.0 pad_tail/impl#[`PadUsing<I, F>`][DoubleEndedIterator]rfold().<B, G>(self, mut init: B, mut f: G) -> B
102 where
103 G: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(B, Selfrust-analyzer cargo itertools 0.14.0 pad_tail/impl#[`PadUsing<I, F>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#) -> B,
104 {
105 init = (self.iterrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#iter..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/fuse/impl#[`Fuse<I>`][ExactSizeIterator]len().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.minrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#min.)
106 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(self.fillerrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#filler.)
107 .rfoldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][DoubleEndedIterator]rfold().(init, &mut f);
108 self.iterrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#iter..rfoldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/fuse/impl#[`Fuse<I>`][DoubleEndedIterator]rfold().(init, f)
109 }
110 }
111
112 impl<I, F> ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator# for PadUsingrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#<I, F>
113 where
114 I: ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator#,
115 F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(usize) -> I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#,
116 {
117 }
118
119 impl<I, F> FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for PadUsingrust-analyzer cargo itertools 0.14.0 pad_tail/PadUsing#<I, F>
120 where
121 I: FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator#,
122 F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(usize) -> I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#,
123 {
124 }