Additional Populatable API tweaks.
This commit is contained in:
parent
f0da76df7c
commit
3018c4a28a
@ -10,19 +10,18 @@ use rustc_serialize::hex::*;
|
||||
use error::EthcoreError;
|
||||
use rand::Rng;
|
||||
use rand::os::OsRng;
|
||||
use bytes::BytesConvertable;
|
||||
use bytes::{BytesConvertable,Populatable};
|
||||
use math::log2;
|
||||
use uint::U256;
|
||||
|
||||
/// Trait for a fixed-size byte array to be used as the output of hash functions.
|
||||
///
|
||||
/// Note: types implementing `FixedHash` must be also `BytesConvertable`.
|
||||
pub trait FixedHash: Sized + BytesConvertable {
|
||||
pub trait FixedHash: Sized + BytesConvertable + Populatable {
|
||||
fn new() -> Self;
|
||||
fn random() -> Self;
|
||||
fn randomize(&mut self);
|
||||
fn size() -> usize;
|
||||
fn as_slice_mut(&mut self) -> &mut [u8];
|
||||
fn from_slice(src: &[u8]) -> Self;
|
||||
fn clone_from_slice(&mut self, src: &[u8]) -> usize;
|
||||
fn shift_bloom<'a, T>(&'a mut self, b: &T) -> &'a mut Self where T: FixedHash;
|
||||
@ -78,10 +77,6 @@ macro_rules! impl_hash {
|
||||
$size
|
||||
}
|
||||
|
||||
fn as_slice_mut(&mut self) -> &mut [u8] {
|
||||
&mut self.0
|
||||
}
|
||||
|
||||
// TODO: remove once slice::clone_from_slice is stable
|
||||
#[inline]
|
||||
fn clone_from_slice(&mut self, src: &[u8]) -> usize {
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
use std::mem::uninitialized;
|
||||
use tiny_keccak::Keccak;
|
||||
use bytes::BytesConvertable;
|
||||
use hash::{FixedHash, H256};
|
||||
use bytes::{BytesConvertable,Populatable};
|
||||
use hash::H256;
|
||||
|
||||
/// Types implementing this trait are sha3able.
|
||||
///
|
||||
|
@ -668,7 +668,7 @@ mod tests {
|
||||
use env_logger;
|
||||
use rand::random;
|
||||
use std::collections::HashSet;
|
||||
use bytes::{ToPretty,Bytes};
|
||||
use bytes::{ToPretty,Bytes,Populatable};
|
||||
use super::super::node::*;
|
||||
use super::super::trietraits::*;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user