haar_lib/misc/
map.rs

1pub trait Map {
2    type Input;
3    type C<T>;
4
5    fn map<Output, F: FnMut(Self::Input) -> Output>(self, f: F) -> Self::C<Output>;
6}
7
8impl<T> Map for Vec<T> {
9    type Input = T;
10    type C<A> = Vec<A>;
11
12    fn map<Output, F: FnMut(Self::Input) -> Output>(self, f: F) -> Self::C<Output> {
13        self.into_iter().map(f).collect()
14    }
15}
16
17#[cfg(test)]
18mod tests {
19    use super::*;
20
21    #[test]
22    fn test() {
23        let a = vec![1, 2, 3];
24        let _b = a.map(|x| x * 2);
25    }
26}