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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*!
# Wrappr
[`wrappr`](self) is a libary for some useful wrapping traits
the 4 trait groups are as follows:
* a [`wrapper`] is a cheap wrapper that constructs a new type, generic over the input type
* a [`composer`] is a potentially costly operation that takes a generic input type, and composes it within itself
* a [`injectable`] is the semantic opposite of a wrapper, it is automatically implemented and is just the object and generic swapped
* a [`embedable`] is the semantic opposite of a composer, it is automatically implemented and is just the object and generic swapped
# Examples
## Wrapper
```rust
# use wrappr::wrapper::Wrapper;
let x: u8 = 1;
let y: u8 = 2;
let z: Vec<u8> = vec![3, 4];
let yz: Vec<u8> = y.wrap(z);
assert_eq!(yz, vec![2, 3, 4]);
let xyz: Vec<u8> = x.wrap(yz);
assert_eq!(xyz, vec![1, 2, 3, 4]);
```
## Composer
```rust
# use wrappr::composer::Composer;
let mut x: Vec<u8> = vec![1, 2];
let y: Vec<u8> = vec![3, 4];
let z: u8 = 5;
x.compose(y);
assert_eq!(x, vec![1, 2, 3, 4]);
x.compose(z);
assert_eq!(x, vec![1, 2, 3, 4, 5]);
```
## Injectable
```rust
# use wrappr::injectable::Injectable;
let x: u8 = 1;
let y: u8 = 2;
let z: Vec<u8> = vec![3, 4];
let yz: Vec<u8> = z.inject(y);
assert_eq!(yz, vec![2, 3, 4]);
let xyz: Vec<u8> = yz.inject(x);
assert_eq!(xyz, vec![1, 2, 3, 4]);
```
## Embedable
```rust
# use wrappr::embedable::Embedable;
let mut x: Vec<u8> = vec![1, 2];
let y: Vec<u8> = vec![3, 4];
let z: u8 = 5;
y.embed(&mut x);
assert_eq!(x, vec![1, 2, 3, 4]);
z.embed(&mut x);
assert_eq!(x, vec![1, 2, 3, 4, 5]);
```
*/
/// implementations for vectors