batch_oper/combin.rs
1//! No nesting combine
2//!
3//! # Tuple example
4//!
5//! ```
6//! # use batch_oper::combin::*;
7//! let a: (i32, u8) = 1.with(2u8);
8//! assert_eq!(a, (1, 2));
9//! ```
10
11/// Make A Tuple  
12/// `A.after(B) -> (B, A)`
13pub trait After<T, Output> {
14    /// Make A Tuple  
15/// `A.after(B) -> (B, A)`
16    fn after(self, v: T) -> Output;
17}
18
19impl<S, T> After<T, (T, S)> for S {
20    fn after(self, v: T) -> (T, S) {
21        (v, self)
22    }
23}
24
25/// Make A Tuple  
26/// `A.after(B) -> (A, B)`
27pub trait With<T, Output> {
28    /// Make A Tuple  
29    /// `A.after(B) -> (A, B)`
30    fn with(self, v: T) -> Output;
31}
32
33impl<S, T> With<T, (S, T)> for S {
34    fn with(self, v: T) -> (S, T) {
35        (self, v)
36    }
37}
38
39#[cfg(test)]
40mod tests {
41    use super::*;
42
43    #[test]
44    fn test_combin_tuple() {
45        let a: (i32, u8) = 1.with(2u8);
46        assert_eq!(a, (1, 2));
47    }
48
49}