From 8a4a413f6535627381a8587c82adc598afcefb33 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 11 Jun 2020 11:50:22 +0200 Subject: [PATCH] Use impl AsRef<...> --- src/blacklist.rs | 2 +- src/config.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/blacklist.rs b/src/blacklist.rs index 0c163c0..486ef9a 100644 --- a/src/blacklist.rs +++ b/src/blacklist.rs @@ -28,7 +28,7 @@ impl BlackList { } } - pub fn load>(path: P) -> Result { + pub fn load(path: impl AsRef) -> Result { let mut map = FxHashMap::default(); let fp = BufReader::new(File::open(path)?); for (line_nb, line) in fp.lines().enumerate() { diff --git a/src/config.rs b/src/config.rs index 192949a..d92e462 100644 --- a/src/config.rs +++ b/src/config.rs @@ -98,7 +98,7 @@ impl Config { Ok(config) } - pub fn from_path>(path: P) -> Result { + pub fn from_path(path: impl AsRef) -> Result { let toml = fs::read_to_string(path)?; Config::from_string(&toml) } @@ -127,7 +127,7 @@ impl State { State::with_key_pair(provider_kp, key_cache_capacity) } - pub async fn async_save>(&self, path: P) -> Result<(), Error> { + pub async fn async_save(&self, path: impl AsRef) -> Result<(), Error> { let path_tmp = path.as_ref().with_extension("tmp"); let mut fpb = tokio::fs::OpenOptions::new(); let fpb = fpb.create(true).write(true); @@ -140,7 +140,7 @@ impl State { Ok(()) } - pub fn from_file>(path: P, key_cache_capacity: usize) -> Result { + pub fn from_file(path: impl AsRef, key_cache_capacity: usize) -> Result { let state_bin = fs::read(path)?; let mut state: State = toml::from_slice(&state_bin)?; for params_set in &mut state.dnscrypt_encryption_params_set {