Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

remove trait bounds from several structs #9055

Merged
merged 1 commit into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ethcore/src/cache_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::hash::Hash;

const COLLECTION_QUEUE_SIZE: usize = 8;

pub struct CacheManager<T> where T: Eq + Hash {
pub struct CacheManager<T> {
pref_cache_size: usize,
max_cache_size: usize,
bytes_per_cache_entry: usize,
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl TransactOptions<trace::NoopTracer, trace::NoopVMTracer> {
}

/// Transaction executor.
pub struct Executive<'a, B: 'a + StateBackend> {
pub struct Executive<'a, B: 'a> {
state: &'a mut State<B>,
info: &'a EnvInfo,
machine: &'a Machine,
Expand Down
4 changes: 1 addition & 3 deletions ethcore/src/externalities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ impl OriginInfo {
}

/// Implementation of evm Externalities.
pub struct Externalities<'a, T: 'a, V: 'a, B: 'a>
where T: Tracer, V: VMTracer, B: StateBackend
{
pub struct Externalities<'a, T: 'a, V: 'a, B: 'a> {
state: &'a mut State<B>,
env_info: &'a EnvInfo,
machine: &'a Machine,
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ pub fn prove_transaction<H: AsHashDB<KeccakHasher> + Send + Sync>(
/// checkpoint can be discarded with `discard_checkpoint`. All of the orignal
/// backed-up values are moved into a parent checkpoint (if any).
///
pub struct State<B: Backend> {
pub struct State<B> {
db: B,
root: H256,
cache: RefCell<HashMap<Address, AccountEntry>>,
Expand Down
12 changes: 9 additions & 3 deletions ethcore/types/src/account_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use bytes::Bytes;

#[derive(Debug, PartialEq, Eq, Clone)]
/// Diff type for specifying a change (or not).
pub enum Diff<T> where T: Eq {
pub enum Diff<T> {
/// Both sides are the same.
Same,
/// Left (pre, source) side doesn't include value, right side (post, destination) does.
Expand All @@ -35,9 +35,15 @@ pub enum Diff<T> where T: Eq {
Died(T),
}

impl<T> Diff<T> where T: Eq {
impl<T> Diff<T> {
/// 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 {
Copy link
Collaborator

@niklasad1 niklasad1 Jul 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not that familiar with derive rules for Eq, but looks a little strange that we have to specify Eq in the constructor (T: Eq) when we have specified it in the derive already!

Can somebody explain this? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derive(Debug) means

impl<T> Debug for Diff<T> where T: Debug {
  // ...
}

so it is a separate impl and has nothing to do with this one

if pre == post {
Diff::Same
} else {
Diff::Changed(pre, post)
}
}

/// 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 } }
Expand Down