Fixing clippy warnings

This commit is contained in:
Tomasz Drwięga 2016-03-11 10:57:58 +01:00
parent 3a4a7ac822
commit 8709dd28f8
17 changed files with 131 additions and 39 deletions

30
Cargo.lock generated
View File

@ -2,7 +2,7 @@
name = "parity" name = "parity"
version = "0.9.99" version = "0.9.99"
dependencies = [ dependencies = [
"clippy 0.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.49 (registry+https://github.com/rust-lang/crates.io-index)",
"ctrlc 1.1.1 (git+https://github.com/tomusdrw/rust-ctrlc.git)", "ctrlc 1.1.1 (git+https://github.com/tomusdrw/rust-ctrlc.git)",
"daemonize 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "daemonize 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)",
@ -94,7 +94,7 @@ dependencies = [
[[package]] [[package]]
name = "clippy" name = "clippy"
version = "0.0.44" version = "0.0.49"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"regex-syntax 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -207,7 +207,7 @@ dependencies = [
name = "ethcore" name = "ethcore"
version = "0.9.99" version = "0.9.99"
dependencies = [ dependencies = [
"clippy 0.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.49 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 0.9.99", "ethash 0.9.99",
@ -234,7 +234,7 @@ dependencies = [
name = "ethcore-rpc" name = "ethcore-rpc"
version = "0.9.99" version = "0.9.99"
dependencies = [ dependencies = [
"clippy 0.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.49 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 0.9.99", "ethash 0.9.99",
"ethcore 0.9.99", "ethcore 0.9.99",
"ethcore-util 0.9.99", "ethcore-util 0.9.99",
@ -258,7 +258,7 @@ dependencies = [
"arrayvec 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"bigint 0.1.0", "bigint 0.1.0",
"chrono 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.49 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -273,7 +273,7 @@ dependencies = [
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rocksdb 0.4.1 (git+https://github.com/arkpar/rust-rocksdb.git)", "rocksdb 0.4.2 (git+https://github.com/arkpar/rust-rocksdb.git)",
"rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
@ -290,7 +290,7 @@ dependencies = [
name = "ethsync" name = "ethsync"
version = "0.9.99" version = "0.9.99"
dependencies = [ dependencies = [
"clippy 0.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.49 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 0.9.99", "ethcore 0.9.99",
"ethcore-util 0.9.99", "ethcore-util 0.9.99",
@ -469,11 +469,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "librocksdb-sys" name = "librocksdb-sys"
version = "0.2.1" version = "0.2.2"
source = "git+https://github.com/arkpar/rust-rocksdb.git#2156621f583bda95c1c07e89e79e4019f75158ee" source = "git+https://github.com/arkpar/rust-rocksdb.git#a4f89fea20ee3ae92b692df65d56426a5c0b6fd5"
dependencies = [ dependencies = [
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -597,11 +596,6 @@ name = "odds"
version = "0.2.12" version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "pkg-config"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "primal" name = "primal"
version = "0.2.3" version = "0.2.3"
@ -697,11 +691,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "rocksdb" name = "rocksdb"
version = "0.4.1" version = "0.4.2"
source = "git+https://github.com/arkpar/rust-rocksdb.git#2156621f583bda95c1c07e89e79e4019f75158ee" source = "git+https://github.com/arkpar/rust-rocksdb.git#a4f89fea20ee3ae92b692df65d56426a5c0b6fd5"
dependencies = [ dependencies = [
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"librocksdb-sys 0.2.1 (git+https://github.com/arkpar/rust-rocksdb.git)", "librocksdb-sys 0.2.2 (git+https://github.com/arkpar/rust-rocksdb.git)",
] ]
[[package]] [[package]]

View File

@ -35,13 +35,13 @@ pub enum ExtrasIndex {
BlocksBlooms = 4, BlocksBlooms = 4,
/// Block receipts index /// Block receipts index
BlockReceipts = 5, BlockReceipts = 5,
} }
/// trait used to write Extras data to db /// trait used to write Extras data to db
pub trait ExtrasWritable { pub trait ExtrasWritable {
/// Write extra data to db /// Write extra data to db
fn put_extras<K, T>(&self, hash: &K, value: &T) where fn put_extras<K, T>(&self, hash: &K, value: &T) where
T: ExtrasIndexable + Encodable, T: ExtrasIndexable + Encodable,
K: ExtrasSliceConvertable; K: ExtrasSliceConvertable;
} }
@ -60,9 +60,9 @@ pub trait ExtrasReadable {
impl ExtrasWritable for DBTransaction { impl ExtrasWritable for DBTransaction {
fn put_extras<K, T>(&self, hash: &K, value: &T) where fn put_extras<K, T>(&self, hash: &K, value: &T) where
T: ExtrasIndexable + Encodable, T: ExtrasIndexable + Encodable,
K: ExtrasSliceConvertable { K: ExtrasSliceConvertable {
self.put(&hash.to_extras_slice(T::extras_index()), &encode(value)).unwrap() self.put(&hash.to_extras_slice(T::extras_index()), &encode(value)).unwrap()
} }
} }
@ -215,6 +215,12 @@ pub struct BlocksBlooms {
pub blooms: [H2048; 16], pub blooms: [H2048; 16],
} }
impl Default for BlocksBlooms {
fn default() -> Self {
BlocksBlooms::new()
}
}
impl BlocksBlooms { impl BlocksBlooms {
pub fn new() -> Self { pub fn new() -> Self {
BlocksBlooms { blooms: unsafe { ::std::mem::zeroed() }} BlocksBlooms { blooms: unsafe { ::std::mem::zeroed() }}

View File

@ -25,6 +25,8 @@
#![cfg_attr(all(nightly, feature="dev"), allow(match_bool))] #![cfg_attr(all(nightly, feature="dev"), allow(match_bool))]
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref. // Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
#![cfg_attr(all(nightly, feature="dev"), allow(clone_on_copy))] #![cfg_attr(all(nightly, feature="dev"), allow(clone_on_copy))]
// In most cases it expresses function flow better
#![cfg_attr(all(nightly, feature="dev"), allow(if_not_else))]
//! Ethcore library //! Ethcore library
//! //!

View File

@ -31,6 +31,12 @@ pub struct Substate {
pub contracts_created: Vec<Address> pub contracts_created: Vec<Address>
} }
impl Default for Substate {
fn default() -> Self {
Substate::new()
}
}
impl Substate { impl Substate {
/// Creates new substate. /// Creates new substate.
pub fn new() -> Self { pub fn new() -> Self {
@ -67,8 +73,8 @@ mod tests {
let mut sub_state = Substate::new(); let mut sub_state = Substate::new();
sub_state.contracts_created.push(address_from_u64(1u64)); sub_state.contracts_created.push(address_from_u64(1u64));
sub_state.logs.push(LogEntry { sub_state.logs.push(LogEntry {
address: address_from_u64(1u64), address: address_from_u64(1u64),
topics: vec![], topics: vec![],
data: vec![] data: vec![]
}); });
sub_state.sstore_clears_count = x!(5); sub_state.sstore_clears_count = x!(5);
@ -77,8 +83,8 @@ mod tests {
let mut sub_state_2 = Substate::new(); let mut sub_state_2 = Substate::new();
sub_state_2.contracts_created.push(address_from_u64(2u64)); sub_state_2.contracts_created.push(address_from_u64(2u64));
sub_state_2.logs.push(LogEntry { sub_state_2.logs.push(LogEntry {
address: address_from_u64(1u64), address: address_from_u64(1u64),
topics: vec![], topics: vec![],
data: vec![] data: vec![]
}); });
sub_state_2.sstore_clears_count = x!(7); sub_state_2.sstore_clears_count = x!(7);

View File

@ -1307,7 +1307,7 @@ impl ChainSync {
where T: Fn(&Address) -> U256 where T: Fn(&Address) -> U256
{ {
let mut queue = self.transaction_queue.lock().unwrap(); let mut queue = self.transaction_queue.lock().unwrap();
queue.add(transaction, fetch_nonce); let _ = queue.add(transaction, fetch_nonce);
} }
} }

View File

@ -17,9 +17,10 @@
#![warn(missing_docs)] #![warn(missing_docs)]
#![cfg_attr(all(nightly, feature="dev"), feature(plugin))] #![cfg_attr(all(nightly, feature="dev"), feature(plugin))]
#![cfg_attr(all(nightly, feature="dev"), plugin(clippy))] #![cfg_attr(all(nightly, feature="dev"), plugin(clippy))]
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref. // Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
#![cfg_attr(all(nightly, feature="dev"), allow(clone_on_copy))] #![cfg_attr(all(nightly, feature="dev"), allow(clone_on_copy))]
// In most cases it expresses function flow better
#![cfg_attr(all(nightly, feature="dev"), allow(if_not_else))]
//! Blockchain sync module //! Blockchain sync module
//! Implements ethereum protocol version 63 as specified here: //! Implements ethereum protocol version 63 as specified here:
@ -172,6 +173,7 @@ impl NetworkProtocolHandler<SyncMessage> for EthSync {
self.sync.write().unwrap().maintain_sync(&mut NetSyncIo::new(io, self.chain.deref())); self.sync.write().unwrap().maintain_sync(&mut NetSyncIo::new(io, self.chain.deref()));
} }
#[allow(single_match)]
fn message(&self, io: &NetworkContext<SyncMessage>, message: &SyncMessage) { fn message(&self, io: &NetworkContext<SyncMessage>, message: &SyncMessage) {
match *message { match *message {
SyncMessage::NewChainBlocks { ref good, ref bad, ref retracted } => { SyncMessage::NewChainBlocks { ref good, ref bad, ref retracted } => {

View File

@ -79,6 +79,7 @@
//! - When it's removed from `current` - all transactions from this sender (`current` & `future`) are recalculated. //! - When it's removed from `current` - all transactions from this sender (`current` & `future`) are recalculated.
//! //!
use std::default::Default;
use std::cmp::{Ordering}; use std::cmp::{Ordering};
use std::collections::{HashMap, BTreeSet}; use std::collections::{HashMap, BTreeSet};
use util::numbers::{Uint, U256}; use util::numbers::{Uint, U256};
@ -102,6 +103,7 @@ struct TransactionOrder {
hash: H256, hash: H256,
} }
impl TransactionOrder { impl TransactionOrder {
fn for_transaction(tx: &VerifiedTransaction, base_nonce: U256) -> Self { fn for_transaction(tx: &VerifiedTransaction, base_nonce: U256) -> Self {
TransactionOrder { TransactionOrder {
@ -253,6 +255,12 @@ pub struct TransactionQueue {
last_nonces: HashMap<Address, U256>, last_nonces: HashMap<Address, U256>,
} }
impl Default for TransactionQueue {
fn default() -> Self {
TransactionQueue::new()
}
}
impl TransactionQueue { impl TransactionQueue {
/// Creates new instance of this Queue /// Creates new instance of this Queue
pub fn new() -> Self { pub fn new() -> Self {

View File

@ -78,9 +78,15 @@ struct AccountUnlock {
expires: DateTime<UTC>, expires: DateTime<UTC>,
} }
impl Default for SecretStore {
fn default() -> Self {
SecretStore::new()
}
}
impl SecretStore { impl SecretStore {
/// new instance of Secret Store in default home directory /// new instance of Secret Store in default home directory
pub fn new() -> SecretStore { pub fn new() -> Self {
let mut path = ::std::env::home_dir().expect("Failed to get home dir"); let mut path = ::std::env::home_dir().expect("Failed to get home dir");
path.push(".parity"); path.push(".parity");
path.push("keys"); path.push("keys");
@ -89,7 +95,7 @@ impl SecretStore {
} }
/// new instance of Secret Store in specific directory /// new instance of Secret Store in specific directory
pub fn new_in(path: &Path) -> SecretStore { pub fn new_in(path: &Path) -> Self {
SecretStore { SecretStore {
directory: KeyDirectory::new(path), directory: KeyDirectory::new(path),
unlocks: RwLock::new(HashMap::new()), unlocks: RwLock::new(HashMap::new()),

View File

@ -16,6 +16,7 @@
//! Key-Value store abstraction with RocksDB backend. //! Key-Value store abstraction with RocksDB backend.
use std::default::Default;
use rocksdb::{DB, Writable, WriteBatch, IteratorMode, DBVector, DBIterator, use rocksdb::{DB, Writable, WriteBatch, IteratorMode, DBVector, DBIterator,
IndexType, Options, DBCompactionStyle, BlockBasedOptions, Direction}; IndexType, Options, DBCompactionStyle, BlockBasedOptions, Direction};
@ -24,6 +25,12 @@ pub struct DBTransaction {
batch: WriteBatch, batch: WriteBatch,
} }
impl Default for DBTransaction {
fn default() -> Self {
DBTransaction::new()
}
}
impl DBTransaction { impl DBTransaction {
/// Create new transaction. /// Create new transaction.
pub fn new() -> DBTransaction { pub fn new() -> DBTransaction {

View File

@ -27,6 +27,8 @@
#![cfg_attr(all(nightly, feature="dev"), allow(match_same_arms))] #![cfg_attr(all(nightly, feature="dev"), allow(match_same_arms))]
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref. // Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
#![cfg_attr(all(nightly, feature="dev"), allow(clone_on_copy))] #![cfg_attr(all(nightly, feature="dev"), allow(clone_on_copy))]
// In most cases it expresses function flow better
#![cfg_attr(all(nightly, feature="dev"), allow(if_not_else))]
//! Ethcore-util library //! Ethcore-util library
//! //!

View File

@ -24,6 +24,7 @@ use hashdb::*;
use heapsize::*; use heapsize::*;
use std::mem; use std::mem;
use std::collections::HashMap; use std::collections::HashMap;
use std::default::Default;
#[derive(Debug,Clone)] #[derive(Debug,Clone)]
/// Reference-counted memory-based HashDB implementation. /// Reference-counted memory-based HashDB implementation.
@ -32,7 +33,7 @@ use std::collections::HashMap;
/// with `kill()`, check for existance with `exists()` and lookup a hash to derive /// with `kill()`, check for existance with `exists()` and lookup a hash to derive
/// the data with `lookup()`. Clear with `clear()` and purge the portions of the data /// the data with `lookup()`. Clear with `clear()` and purge the portions of the data
/// that have no references with `purge()`. /// that have no references with `purge()`.
/// ///
/// # Example /// # Example
/// ```rust /// ```rust
/// extern crate ethcore_util; /// extern crate ethcore_util;
@ -74,6 +75,12 @@ pub struct MemoryDB {
static_null_rlp: (Bytes, i32), static_null_rlp: (Bytes, i32),
} }
impl Default for MemoryDB {
fn default() -> Self {
MemoryDB::new()
}
}
impl MemoryDB { impl MemoryDB {
/// Create a new instance of the memory DB. /// Create a new instance of the memory DB.
pub fn new() -> MemoryDB { pub fn new() -> MemoryDB {
@ -133,7 +140,7 @@ impl MemoryDB {
/// Denote than an existing value has the given key. Used when a key gets removed without /// Denote than an existing value has the given key. Used when a key gets removed without
/// a prior insert and thus has a negative reference with no value. /// a prior insert and thus has a negative reference with no value.
/// ///
/// May safely be called even if the key's value is known, in which case it will be a no-op. /// May safely be called even if the key's value is known, in which case it will be a no-op.
pub fn denote(&self, key: &H256, value: Bytes) -> &(Bytes, i32) { pub fn denote(&self, key: &H256, value: Bytes) -> &(Bytes, i32) {
if self.raw(key) == None { if self.raw(key) == None {

View File

@ -19,6 +19,7 @@ use std::net::SocketAddr;
use std::collections::{HashSet, HashMap, BTreeMap, VecDeque}; use std::collections::{HashSet, HashMap, BTreeMap, VecDeque};
use std::mem; use std::mem;
use std::cmp; use std::cmp;
use std::default::Default;
use mio::*; use mio::*;
use mio::udp::*; use mio::udp::*;
use sha3::*; use sha3::*;
@ -62,8 +63,14 @@ struct NodeBucket {
nodes: VecDeque<BucketEntry>, //sorted by last active nodes: VecDeque<BucketEntry>, //sorted by last active
} }
impl Default for NodeBucket {
fn default() -> Self {
NodeBucket::new()
}
}
impl NodeBucket { impl NodeBucket {
fn new() -> NodeBucket { fn new() -> Self {
NodeBucket { NodeBucket {
nodes: VecDeque::new() nodes: VecDeque::new()
} }

View File

@ -23,6 +23,7 @@ use std::ops::*;
use std::cmp::min; use std::cmp::min;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::default::Default;
use std::fs; use std::fs;
use mio::*; use mio::*;
use mio::tcp::*; use mio::tcp::*;
@ -75,9 +76,15 @@ pub struct NetworkConfiguration {
pub ideal_peers: u32, pub ideal_peers: u32,
} }
impl Default for NetworkConfiguration {
fn default() -> Self {
NetworkConfiguration::new()
}
}
impl NetworkConfiguration { impl NetworkConfiguration {
/// Create a new instance of default settings. /// Create a new instance of default settings.
pub fn new() -> NetworkConfiguration { pub fn new() -> Self {
NetworkConfiguration { NetworkConfiguration {
config_path: None, config_path: None,
listen_address: None, listen_address: None,

View File

@ -19,6 +19,7 @@
use std::thread; use std::thread;
use std::ops::DerefMut; use std::ops::DerefMut;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::default::Default;
/// Thread-safe closure for handling possible panics /// Thread-safe closure for handling possible panics
pub trait OnPanicListener: Send + Sync + 'static { pub trait OnPanicListener: Send + Sync + 'static {
@ -56,14 +57,20 @@ pub struct PanicHandler {
listeners: Mutex<Vec<Box<OnPanicListener>>> listeners: Mutex<Vec<Box<OnPanicListener>>>
} }
impl Default for PanicHandler {
fn default() -> Self {
PanicHandler::new()
}
}
impl PanicHandler { impl PanicHandler {
/// Creates new `PanicHandler` wrapped in `Arc` /// Creates new `PanicHandler` wrapped in `Arc`
pub fn new_in_arc() -> Arc<PanicHandler> { pub fn new_in_arc() -> Arc<Self> {
Arc::new(Self::new()) Arc::new(Self::new())
} }
/// Creates new `PanicHandler` /// Creates new `PanicHandler`
pub fn new() -> PanicHandler { pub fn new() -> Self {
PanicHandler { PanicHandler {
listeners: Mutex::new(vec![]) listeners: Mutex::new(vec![])
} }

View File

@ -15,6 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::ops::Deref; use std::ops::Deref;
use std::default::Default;
use elastic_array::*; use elastic_array::*;
use rlp::bytes::{ToBytes, VecLike}; use rlp::bytes::{ToBytes, VecLike};
use rlp::{Stream, Encoder, Encodable}; use rlp::{Stream, Encoder, Encodable};
@ -44,6 +45,12 @@ pub struct RlpStream {
finished_list: bool, finished_list: bool,
} }
impl Default for RlpStream {
fn default() -> Self {
RlpStream::new()
}
}
impl Stream for RlpStream { impl Stream for RlpStream {
fn new() -> Self { fn new() -> Self {
RlpStream { RlpStream {
@ -190,8 +197,14 @@ struct BasicEncoder {
bytes: ElasticArray1024<u8>, bytes: ElasticArray1024<u8>,
} }
impl Default for BasicEncoder {
fn default() -> Self {
BasicEncoder::new()
}
}
impl BasicEncoder { impl BasicEncoder {
fn new() -> BasicEncoder { fn new() -> Self {
BasicEncoder { bytes: ElasticArray1024::new() } BasicEncoder { bytes: ElasticArray1024::new() }
} }
@ -222,7 +235,7 @@ impl Encoder for BasicEncoder {
// just 0 // just 0
0 => self.bytes.push(0x80u8), 0 => self.bytes.push(0x80u8),
// byte is its own encoding if < 0x80 // byte is its own encoding if < 0x80
1 => { 1 => {
value.to_bytes(&mut self.bytes); value.to_bytes(&mut self.bytes);
let len = self.bytes.len(); let len = self.bytes.len();
let last_byte = self.bytes[len - 1]; let last_byte = self.bytes[len - 1];

View File

@ -16,6 +16,7 @@
//! A collection associating pair of keys (row and column) with a single value. //! A collection associating pair of keys (row and column) with a single value.
use std::default::Default;
use std::hash::Hash; use std::hash::Hash;
use std::collections::HashMap; use std::collections::HashMap;
@ -30,11 +31,21 @@ pub struct Table<Row, Col, Val>
map: HashMap<Row, HashMap<Col, Val>>, map: HashMap<Row, HashMap<Col, Val>>,
} }
impl<Row, Col, Val> Default for Table<Row, Col, Val>
where Row: Eq + Hash + Clone,
Col: Eq + Hash {
fn default() -> Self {
Table::new()
}
}
// There is default but clippy does not detect it?
#[allow(new_without_default)]
impl<Row, Col, Val> Table<Row, Col, Val> impl<Row, Col, Val> Table<Row, Col, Val>
where Row: Eq + Hash + Clone, where Row: Eq + Hash + Clone,
Col: Eq + Hash { Col: Eq + Hash {
/// Creates new Table /// Creates new Table
pub fn new() -> Table<Row, Col, Val> { pub fn new() -> Self {
Table { Table {
map: HashMap::new(), map: HashMap::new(),
} }

View File

@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::default::Default;
use sha3::*; use sha3::*;
use hash::H256; use hash::H256;
use bytes::*; use bytes::*;
@ -39,6 +40,12 @@ pub struct Score {
#[derive(Debug)] #[derive(Debug)]
pub struct Journal (Vec<Operation>); pub struct Journal (Vec<Operation>);
impl Default for Journal {
fn default() -> Self {
Journal::new()
}
}
impl Journal { impl Journal {
/// Create a new, empty, object. /// Create a new, empty, object.
pub fn new() -> Journal { Journal(vec![]) } pub fn new() -> Journal { Journal(vec![]) }