concision_core/traits/
ops.rs1pub trait Apply<T, F> {
7 type Output;
8
9 fn apply<U>(&self, f: F) -> Self::Output
10 where
11 F: Fn(T) -> U;
12
13 fn apply_mut<U>(&mut self, f: F) -> Self::Output
14 where
15 F: FnMut(T) -> U;
16}
17
18pub trait ApplyOn<T, F> {
19 type Output;
20
21 fn apply<U>(self, f: F) -> Self::Output
22 where
23 F: FnMut(T) -> U;
24}
25
26pub trait Transform<T> {
27 type Output;
28
29 fn transform(&self, args: &T) -> Self::Output;
30}
31
32impl<T, F, S> ApplyOn<T, F> for S
36where
37 S: Iterator<Item = T>,
38{
39 type Output = core::iter::Map<S, F>;
40
41 fn apply<U>(self, f: F) -> Self::Output
42 where
43 F: FnMut(T) -> U,
44 {
45 self.map(f)
46 }
47}