type_toppings/
iterator.rs1pub mod map_into;
2pub mod map_opt;
3pub mod map_res;
4pub mod map_res_err;
5
6impl<I> crate::IteratorExt for I
7where
8 I: Iterator,
9{
10 fn map_into<U>(self) -> map_into::MapInto<Self, U>
11 where
12 Self: Sized,
13 Self: Iterator,
14 <Self as Iterator>::Item: Into<U>,
15 {
16 map_into::MapInto {
17 iter: self,
18 _marker: std::marker::PhantomData,
19 }
20 }
21
22 fn map_opt<T, U, F>(self, f: F) -> map_opt::MapOpt<Self, F>
23 where
24 Self: Sized,
25 Self: Iterator<Item = Option<T>>,
26 F: FnMut(T) -> U,
27 {
28 map_opt::MapOpt { iter: self, f }
29 }
30
31 fn map_res<F, T, U, E>(self, f: F) -> map_res::MapRes<Self, F>
32 where
33 Self: Sized,
34 Self: Iterator<Item = Result<T, E>>,
35 F: FnMut(T) -> U,
36 {
37 map_res::MapRes { iter: self, f }
38 }
39
40 fn map_res_err<F, T, U, E>(self, f: F) -> map_res_err::MapResErr<Self, F>
41 where
42 Self: Sized,
43 Self: Iterator<Item = Result<T, E>>,
44 F: FnMut(E) -> U,
45 {
46 map_res_err::MapResErr { iter: self, f }
47 }
48
49 fn join_as_strings(self, separator: &str) -> String
50 where
51 Self: Iterator,
52 <Self as Iterator>::Item: ToString,
53 {
54 self.map(|x| x.to_string()).collect::<Vec<_>>().join(separator)
56 }
57}