1
use std::collections::HashSet;
2
use std::fmt::Debug;
3
use std::hash::Hash;
4

            
5
5
pub fn assert_eq_any_order<T: Eq + Hash + Debug + Clone>(a: &Vec<Vec<T>>, b: &Vec<Vec<T>>) {
6
5
    assert_eq!(a.len(), b.len());
7

            
8
5
    let mut a_rows: Vec<HashSet<T>> = Vec::new();
9
12
    for row in a {
10
7
        let hash_row = to_set(row);
11
7
        a_rows.push(hash_row);
12
7
    }
13

            
14
5
    let mut b_rows: Vec<HashSet<T>> = Vec::new();
15
12
    for row in b {
16
7
        let hash_row = to_set(row);
17
7
        b_rows.push(hash_row);
18
7
    }
19

            
20
5
    println!("{:?},{:?}", a_rows, b_rows);
21
12
    for row in a_rows {
22
7
        assert!(b_rows.contains(&row));
23
    }
24
5
}
25

            
26
14
pub fn to_set<T: Eq + Hash + Debug + Clone>(a: &Vec<T>) -> HashSet<T> {
27
14
    let mut a_set: HashSet<T> = HashSet::new();
28
36
    for el in a {
29
22
        a_set.insert(el.clone());
30
22
    }
31
14
    a_set
32
14
}
33

            
34
6
pub fn if_ok<T, E: Debug>(result: Result<T, E>) -> T {
35
6
    assert!(result.is_ok());
36
6
    result.unwrap()
37
6
}