remove trait bounds from several structs (#9055)

This commit is contained in:
Marek Kotewicz 2018-07-09 13:55:27 +02:00 committed by André Silva
parent 701692b7d3
commit c7d21841a4
5 changed files with 13 additions and 9 deletions

View File

@ -19,7 +19,7 @@ use std::hash::Hash;
const COLLECTION_QUEUE_SIZE: usize = 8; const COLLECTION_QUEUE_SIZE: usize = 8;
pub struct CacheManager<T> where T: Eq + Hash { pub struct CacheManager<T> {
pref_cache_size: usize, pref_cache_size: usize,
max_cache_size: usize, max_cache_size: usize,
bytes_per_cache_entry: usize, bytes_per_cache_entry: usize,

View File

@ -163,7 +163,7 @@ impl TransactOptions<trace::NoopTracer, trace::NoopVMTracer> {
} }
/// Transaction executor. /// Transaction executor.
pub struct Executive<'a, B: 'a + StateBackend> { pub struct Executive<'a, B: 'a> {
state: &'a mut State<B>, state: &'a mut State<B>,
info: &'a EnvInfo, info: &'a EnvInfo,
machine: &'a Machine, machine: &'a Machine,

View File

@ -63,9 +63,7 @@ impl OriginInfo {
} }
/// Implementation of evm Externalities. /// Implementation of evm Externalities.
pub struct Externalities<'a, T: 'a, V: 'a, B: 'a> pub struct Externalities<'a, T: 'a, V: 'a, B: 'a> {
where T: Tracer, V: VMTracer, B: StateBackend
{
state: &'a mut State<B>, state: &'a mut State<B>,
env_info: &'a EnvInfo, env_info: &'a EnvInfo,
machine: &'a Machine, machine: &'a Machine,

View File

@ -305,7 +305,7 @@ pub fn prove_transaction<H: AsHashDB<KeccakHasher> + Send + Sync>(
/// checkpoint can be discarded with `discard_checkpoint`. All of the orignal /// checkpoint can be discarded with `discard_checkpoint`. All of the orignal
/// backed-up values are moved into a parent checkpoint (if any). /// backed-up values are moved into a parent checkpoint (if any).
/// ///
pub struct State<B: Backend> { pub struct State<B> {
db: B, db: B,
root: H256, root: H256,
cache: RefCell<HashMap<Address, AccountEntry>>, cache: RefCell<HashMap<Address, AccountEntry>>,

View File

@ -24,7 +24,7 @@ use bytes::Bytes;
#[derive(Debug, PartialEq, Eq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
/// Diff type for specifying a change (or not). /// Diff type for specifying a change (or not).
pub enum Diff<T> where T: Eq { pub enum Diff<T> {
/// Both sides are the same. /// Both sides are the same.
Same, Same,
/// Left (pre, source) side doesn't include value, right side (post, destination) does. /// Left (pre, source) side doesn't include value, right side (post, destination) does.
@ -35,9 +35,15 @@ pub enum Diff<T> where T: Eq {
Died(T), Died(T),
} }
impl<T> Diff<T> where T: Eq { impl<T> Diff<T> {
/// Construct new object with given `pre` and `post`. /// Construct new object with given `pre` and `post`.
pub fn new(pre: T, post: T) -> Self { if pre == post { Diff::Same } else { Diff::Changed(pre, post) } } pub fn new(pre: T, post: T) -> Self where T: Eq {
if pre == post {
Diff::Same
} else {
Diff::Changed(pre, post)
}
}
/// Get the before value, if there is one. /// Get the before value, if there is one.
pub fn pre(&self) -> Option<&T> { match *self { Diff::Died(ref x) | Diff::Changed(ref x, _) => Some(x), _ => None } } pub fn pre(&self) -> Option<&T> { match *self { Diff::Died(ref x) | Diff::Changed(ref x, _) => Some(x), _ => None } }