Fixing clippy warnings (#1660)

This commit is contained in:
Tomasz Drwięga
2016-07-19 09:25:51 +02:00
committed by Gav Wood
parent 340f0b6f58
commit 038862fa9d
9 changed files with 31 additions and 26 deletions

View File

@@ -81,6 +81,7 @@ macro_rules! map_into {
#[macro_export]
macro_rules! flush {
($arg:expr) => ($crate::flush($arg.into()));
($($arg:tt)*) => ($crate::flush(format!("{}", format_args!($($arg)*))));
}

View File

@@ -33,7 +33,7 @@ impl IoHandler<NetworkIoMessage> for HostHandler {
fn message(&self, _io: &IoContext<NetworkIoMessage>, message: &NetworkIoMessage) {
if let NetworkIoMessage::NetworkStarted(ref public_url) = *message {
let mut url = self.public_url.write();
if url.as_ref().map(|uref| uref != public_url).unwrap_or(true) {
if url.as_ref().map_or(true, |uref| uref != public_url) {
info!(target: "network", "Public node URL: {}", Colour::White.bold().paint(public_url.as_ref()));
}
*url = Some(public_url.to_owned());

View File

@@ -122,7 +122,7 @@ impl Node {
// encode a node to RLP
// TODO: parallelize
fn to_rlp<F>(self, mut child_cb: F) -> ElasticArray1024<u8>
fn into_rlp<F>(self, mut child_cb: F) -> ElasticArray1024<u8>
where F: FnMut(NodeHandle, &mut RlpStream)
{
match self {
@@ -183,7 +183,7 @@ enum InsertAction {
}
impl InsertAction {
fn as_action(self) -> Action {
fn into_action(self) -> Action {
match self {
InsertAction::Replace(n) => Action::Replace(n),
InsertAction::Restore(n) => Action::Restore(n),
@@ -442,13 +442,14 @@ impl<'a> TrieDBMut<'a> {
};
let stored = self.storage.destroy(h);
let (new_stored, changed) = self.inspect(stored, move |trie, stored| {
trie.insert_inspector(stored, partial, value).as_action()
trie.insert_inspector(stored, partial, value).into_action()
}).expect("Insertion never deletes.");
(self.storage.alloc(new_stored), changed)
}
/// the insertion inspector.
#[cfg_attr(feature = "dev", allow(cyclomatic_complexity))]
fn insert_inspector(&mut self, node: Node, partial: NibbleSlice, value: Bytes) -> InsertAction {
trace!(target: "trie", "augmented (partial: {:?}, value: {:?})", partial, value.pretty());
@@ -819,7 +820,7 @@ impl<'a> TrieDBMut<'a> {
match self.storage.destroy(handle) {
Stored::New(node) => {
let root_rlp = node.to_rlp(|child, stream| self.commit_node(child, stream));
let root_rlp = node.into_rlp(|child, stream| self.commit_node(child, stream));
*self.root = self.db.insert(&root_rlp[..]);
self.hash_count += 1;
@@ -842,7 +843,7 @@ impl<'a> TrieDBMut<'a> {
NodeHandle::InMemory(h) => match self.storage.destroy(h) {
Stored::Cached(_, h) => stream.append(&h),
Stored::New(node) => {
let node_rlp = node.to_rlp(|child, stream| self.commit_node(child, stream));
let node_rlp = node.into_rlp(|child, stream| self.commit_node(child, stream));
if node_rlp.len() >= 32 {
let hash = self.db.insert(&node_rlp[..]);
self.hash_count += 1;
@@ -1257,4 +1258,4 @@ mod tests {
assert!(t.is_empty());
assert_eq!(*t.root(), SHA3_NULL_RLP);
}
}
}