Impl ssz enc/dec for NonZeroUsize

This commit is contained in:
Paul Hauner
2019-06-04 12:24:13 +10:00
parent 7a2ab2e9aa
commit 45fb11b208
2 changed files with 38 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
use super::*;
use core::num::NonZeroUsize;
use ethereum_types::{H256, U128, U256};
macro_rules! impl_encodable_for_uint {
@@ -80,6 +81,20 @@ impl Encode for bool {
}
}
impl Encode for NonZeroUsize {
fn is_ssz_fixed_len() -> bool {
<usize as Encode>::is_ssz_fixed_len()
}
fn ssz_fixed_len() -> usize {
<usize as Encode>::ssz_fixed_len()
}
fn ssz_append(&self, buf: &mut Vec<u8>) {
self.get().ssz_append(buf)
}
}
impl Encode for H256 {
fn is_ssz_fixed_len() -> bool {
true