1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
pub trait Chain<N> {
type Chained;
fn chain(self, next: N) -> Self::Chained;
}
impl<T> Chain<T> for Vec<T> {
type Chained = Vec<T>;
fn chain(mut self, next: T) -> Self::Chained {
self.push(next);
self
}
}
impl<T> Chain<Vec<T>> for T {
type Chained = Vec<T>;
fn chain(self, mut next: Vec<T>) -> Self::Chained {
let mut this = vec![self];
this.append(&mut next);
this
}
}
impl<T> Chain<Vec<T>> for Vec<T> {
type Chained = Vec<T>;
fn chain(mut self, mut next: Vec<T>) -> Self::Chained {
self.append(&mut next);
self
}
}