Simultaneous referendums and multiple voting variants.

This commit is contained in:
Gav
2018-03-03 11:26:56 +01:00
parent f5515ff673
commit 6cf236fb02
2 changed files with 215 additions and 78 deletions
+8 -29
View File
@@ -25,33 +25,12 @@ pub trait KeyedVec {
fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>;
}
macro_rules! impl_non_endians {
( $( $t:ty ),* ) => { $(
impl KeyedVec for $t {
fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8> {
let mut r = prepend_key.to_vec();
r.extend(&self[..]);
r
}
}
)* }
impl<T: Slicable> KeyedVec for T {
fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8> {
self.using_encoded(|slice| {
let mut r = prepend_key.to_vec();
r.extend(slice);
r
})
}
}
macro_rules! impl_endians {
( $( $t:ty ),* ) => { $(
impl KeyedVec for $t {
fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8> {
self.using_encoded(|slice| {
let mut r = prepend_key.to_vec();
r.extend(slice);
r
})
}
}
)* }
}
impl_endians!(u8, i8, u16, u32, u64, usize, i16, i32, i64, isize);
impl_non_endians!([u8; 1], [u8; 2], [u8; 3], [u8; 4], [u8; 5], [u8; 6], [u8; 7], [u8; 8],
[u8; 10], [u8; 12], [u8; 14], [u8; 16], [u8; 20], [u8; 24], [u8; 28], [u8; 32], [u8; 40],
[u8; 48], [u8; 56], [u8; 64], [u8; 80], [u8; 96], [u8; 112], [u8; 128]);