-
Notifications
You must be signed in to change notification settings - Fork 242
/
Copy pathmk_key.rs
109 lines (104 loc) · 2.72 KB
/
mk_key.rs
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
109
pub(super) trait MakeKey<A> {
fn from_row(key: &[usize], row: &[A]) -> Self;
fn from_key(key: &[A]) -> Self;
}
impl<A: Clone> MakeKey<A> for (A, A) {
#[inline(always)]
fn from_row(key: &[usize], row: &[A]) -> Self {
debug_assert_eq!(key.len(), 2);
(row[key[0]].clone(), row[key[1]].clone())
}
#[inline(always)]
fn from_key(key: &[A]) -> Self {
debug_assert_eq!(key.len(), 2);
(key[0].clone(), key[1].clone())
}
}
impl<A: Clone> MakeKey<A> for (A, A, A) {
#[inline(always)]
fn from_row(key: &[usize], row: &[A]) -> Self {
debug_assert_eq!(key.len(), 3);
(
row[key[0]].clone(),
row[key[1]].clone(),
row[key[2]].clone(),
)
}
#[inline(always)]
fn from_key(key: &[A]) -> Self {
debug_assert_eq!(key.len(), 3);
(key[0].clone(), key[1].clone(), key[2].clone())
}
}
impl<A: Clone> MakeKey<A> for (A, A, A, A) {
#[inline(always)]
fn from_row(key: &[usize], row: &[A]) -> Self {
debug_assert_eq!(key.len(), 4);
(
row[key[0]].clone(),
row[key[1]].clone(),
row[key[2]].clone(),
row[key[3]].clone(),
)
}
#[inline(always)]
fn from_key(key: &[A]) -> Self {
debug_assert_eq!(key.len(), 4);
(
key[0].clone(),
key[1].clone(),
key[2].clone(),
key[3].clone(),
)
}
}
impl<A: Clone> MakeKey<A> for (A, A, A, A, A) {
#[inline(always)]
fn from_row(key: &[usize], row: &[A]) -> Self {
debug_assert_eq!(key.len(), 5);
(
row[key[0]].clone(),
row[key[1]].clone(),
row[key[2]].clone(),
row[key[3]].clone(),
row[key[4]].clone(),
)
}
#[inline(always)]
fn from_key(key: &[A]) -> Self {
debug_assert_eq!(key.len(), 5);
(
key[0].clone(),
key[1].clone(),
key[2].clone(),
key[3].clone(),
key[4].clone(),
)
}
}
impl<A: Clone> MakeKey<A> for (A, A, A, A, A, A) {
#[inline(always)]
fn from_row(key: &[usize], row: &[A]) -> Self {
debug_assert_eq!(key.len(), 6);
(
row[key[0]].clone(),
row[key[1]].clone(),
row[key[2]].clone(),
row[key[3]].clone(),
row[key[4]].clone(),
row[key[5]].clone(),
)
}
#[inline(always)]
fn from_key(key: &[A]) -> Self {
debug_assert_eq!(key.len(), 6);
(
key[0].clone(),
key[1].clone(),
key[2].clone(),
key[3].clone(),
key[4].clone(),
key[5].clone(),
)
}
}