]>
Commit | Line | Data |
---|---|---|
0731742a | 1 | trait SipHash { |
223e47cc LB |
2 | fn result(&self) -> u64; |
3 | fn reset(&self); | |
4 | } | |
5 | ||
9cc50fc6 | 6 | fn siphash(k0 : u64, k1 : u64) { |
223e47cc LB |
7 | struct SipState { |
8 | v0: u64, | |
9 | v1: u64, | |
10 | } | |
11 | ||
9cc50fc6 | 12 | fn mk_result(st : &SipState) -> u64 { |
223e47cc | 13 | |
970d7e83 LB |
14 | let v0 = st.v0; |
15 | let v1 = st.v1; | |
223e47cc LB |
16 | return v0 ^ v1; |
17 | } | |
18 | ||
0731742a | 19 | impl SipHash for SipState { |
223e47cc | 20 | fn reset(&self) { |
1a4d82fc | 21 | self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR can't capture dynamic environment |
1a4d82fc | 22 | self.v1 = k1 ^ 0x646f72616e646f6d; //~ ERROR can't capture dynamic environment |
223e47cc LB |
23 | } |
24 | fn result(&self) -> u64 { return mk_result(self); } | |
25 | } | |
26 | } | |
27 | ||
28 | fn main() {} |