Cleaning up clippy warning
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Armin Friedl 2020-02-08 10:27:15 +01:00
parent 6a22429632
commit 7515462433
Signed by: armin
GPG key ID: 48C726EEE7FBCBC8
5 changed files with 9 additions and 7 deletions

View file

@ -5,7 +5,7 @@ use env_logger;
use structopt::StructOpt;
use std:: {
net::{SocketAddr, TcpStream},
net::TcpStream,
error::Error,
path::PathBuf,
io::{Write, Read},

View file

@ -44,7 +44,7 @@ pub struct Keyring {
impl Keyring {
pub fn new(certificate: Certificate) -> Keyring {
Keyring {
certificate: certificate,
certificate,
known_keys: HashMap::new()
}
}

View file

@ -10,7 +10,7 @@ pub fn generate_key(out: PathBuf) {
let cert = certificate.to_cbor().unwrap();
let mut writer = File::create(&out)
.expect(&format!{"Could not create out file {}", &out.display()});
.unwrap_or_else(|_| panic!{"Could not create out file {}", &out.display()});
writer.write_all(&cert).unwrap();
}

View file

@ -7,7 +7,7 @@ use std::sync::RwLock;
use std::sync::RwLockReadGuard;
use std::sync::RwLockWriteGuard;
use std::collections::HashMap;
use std::collections::hash_map::{HashMap, Entry};
use coffer_common::coffer::*;
@ -34,8 +34,10 @@ impl Coffer for CofferMap {
match lock.get_mut(&key.shard) {
Some(shard) => {
if shard.contains_key(&key.key) { Err(CofferError::Msg("Key exists")) }
else { shard.insert(key.key, value); Ok(()) }
match shard.entry(key.key) {
Entry::Occupied(_) => Err(CofferError::Msg("Key exists")),
Entry::Vacant(v) => { v.insert(value); Ok(()) }
}
}
None => {
lock.insert(key.shard.clone(), HashMap::new());

View file

@ -59,7 +59,7 @@ where C: Coffer + Send + Sync + 'static
debug!{"Binding to socket {:?}", socket}
let mut listener = TcpListener::bind(socket).await
.expect(format!{"Could not bind to socket {}", socket}.as_str());
.expect("Could not bind to socket");
let server = async move {
let mut incoming = listener.incoming();