1use crate::{ScanClone, ScanCopy, ScanStateClone, ScanStateCopy, ScanWithTuple};
2
3pub trait IterScan: Iterator + Sized {
5 #[doc = include_str!("../docs/scan-clone.md")]
6 fn scan_clone<Compute, State>(
7 self,
8 initial: State,
9 compute: Compute,
10 ) -> ScanClone<Self, Compute, State>
11 where
12 State: Clone,
13 Compute: FnMut(State, Self::Item) -> State,
14 {
15 ScanClone::new(self, initial, compute)
16 }
17
18 #[doc = include_str!("../docs/scan-copy.md")]
19 fn scan_copy<Compute, State>(
20 self,
21 initial: State,
22 compute: Compute,
23 ) -> ScanCopy<Self, Compute, State>
24 where
25 State: Copy,
26 Compute: FnMut(State, Self::Item) -> State,
27 {
28 ScanCopy::new(self, initial, compute)
29 }
30
31 #[doc = include_str!("../docs/scan-state-clone.md")]
32 fn scan_state_clone<Compute, State, Value>(
33 self,
34 initial: State,
35 compute: Compute,
36 ) -> ScanStateClone<Self, Compute, State, Value>
37 where
38 State: Clone,
39 Compute: FnMut(State, Self::Item) -> (State, Value),
40 {
41 ScanStateClone::new(self, initial, compute)
42 }
43
44 #[doc = include_str!("../docs/scan-state-copy.md")]
45 fn scan_state_copy<Compute, State, Value>(
46 self,
47 initial: State,
48 compute: Compute,
49 ) -> ScanStateCopy<Self, Compute, State, Value>
50 where
51 State: Copy,
52 Compute: FnMut(State, Self::Item) -> (State, Value),
53 {
54 ScanStateCopy::new(self, initial, compute)
55 }
56
57 #[doc = include_str!("../docs/scan-with-tuple.md")]
58 fn scan_with_tuple<Compute, State, Value>(
59 self,
60 initial: State,
61 compute: Compute,
62 ) -> ScanWithTuple<Self, Compute, State, Value>
63 where
64 Compute: FnMut(State, Self::Item) -> (State, Value),
65 {
66 ScanWithTuple::new(self, initial, compute)
67 }
68}
69
70impl<X: Iterator + Sized> IterScan for X {}