[ci] Fix clippy warnings, enable clippy checks

This commit is contained in:
Steve Myers
2020-10-07 14:18:50 -07:00
parent 6402fd07c2
commit aea9abff8a
15 changed files with 69 additions and 68 deletions

View File

@@ -314,7 +314,7 @@ impl Database for Tree {
let is_internal = serde_json::from_value(val["i"].take())?;
Ok(UTXO {
outpoint: outpoint.clone(),
outpoint: *outpoint,
txout,
is_internal,
})

View File

@@ -77,7 +77,7 @@ impl MapKey<'_> {
fn serialize_content(&self) -> Vec<u8> {
match self {
MapKey::Path((_, Some(child))) => u32::from(*child).to_be_bytes().to_vec(),
MapKey::Path((_, Some(child))) => child.to_be_bytes().to_vec(),
MapKey::Script(Some(s)) => serialize(*s),
MapKey::UTXO(Some(s)) => serialize(*s),
MapKey::RawTx(Some(s)) => serialize(*s),
@@ -94,8 +94,8 @@ impl MapKey<'_> {
}
}
fn after(key: &Vec<u8>) -> Vec<u8> {
let mut key = key.clone();
fn after(key: &[u8]) -> Vec<u8> {
let mut key = key.to_owned();
let mut idx = key.len();
while idx > 0 {
if key[idx - 1] == 0xFF {
@@ -233,7 +233,7 @@ impl BatchOperations for MemoryDatabase {
Some(b) => {
let (txout, is_internal) = b.downcast_ref().cloned().unwrap();
Ok(Some(UTXO {
outpoint: outpoint.clone(),
outpoint: *outpoint,
txout,
is_internal,
}))
@@ -387,7 +387,7 @@ impl Database for MemoryDatabase {
Ok(self.map.get(&key).map(|b| {
let (txout, is_internal) = b.downcast_ref().cloned().unwrap();
UTXO {
outpoint: outpoint.clone(),
outpoint: *outpoint,
txout,
is_internal,
}
@@ -424,9 +424,9 @@ impl Database for MemoryDatabase {
let key = MapKey::LastIndex(script_type).as_map_key();
let value = self
.map
.entry(key.clone())
.entry(key)
.and_modify(|x| *x.downcast_mut::<u32>().unwrap() += 1)
.or_insert(Box::<u32>::new(0))
.or_insert_with(|| Box::<u32>::new(0))
.downcast_mut()
.unwrap();
@@ -445,8 +445,8 @@ impl BatchDatabase for MemoryDatabase {
for key in batch.deleted_keys {
self.map.remove(&key);
}
Ok(self.map.append(&mut batch.map))
self.map.append(&mut batch.map);
Ok(())
}
}

View File

@@ -191,7 +191,7 @@ pub(crate) trait DatabaseUtils: Database {
self.get_raw_tx(&outpoint.txid)?
.map(|previous_tx| {
if outpoint.vout as usize >= previous_tx.output.len() {
Err(Error::InvalidOutpoint(outpoint.clone()))
Err(Error::InvalidOutpoint(*outpoint))
} else {
Ok(previous_tx.output[outpoint.vout as usize].clone())
}