From a5e9966624375f61a57d080a53d5c9b140cdaeee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Thu, 27 Jun 2019 22:41:56 -0700 Subject: [PATCH] refactor(get): move trait bounds into where clauses --- src/get.rs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/get.rs b/src/get.rs index f392192..d58907a 100644 --- a/src/get.rs +++ b/src/get.rs @@ -45,7 +45,11 @@ where }) } -pub fn read, K: AsRef>(cache: P, key: K) -> Result, Error> { +pub fn read(cache: P, key: K) -> Result, Error> +where + P: AsRef, + K: AsRef, +{ if let Some(entry) = index::find(cache.as_ref(), key.as_ref())? { read_hash(cache, &entry.integrity) } else { @@ -53,11 +57,19 @@ pub fn read, K: AsRef>(cache: P, key: K) -> Result, } } -pub fn read_hash>(cache: P, sri: &Integrity) -> Result, Error> { +pub fn read_hash

(cache: P, sri: &Integrity) -> Result, Error> +where + P: AsRef +{ Ok(read::read(cache.as_ref(), sri)?) } -pub fn copy, K: AsRef>(cache: P, key: K, to: P) -> Result { +pub fn copy(cache: P, key: K, to: Q) -> Result +where + P: AsRef, + K: AsRef, + Q: AsRef, +{ if let Some(entry) = index::find(cache.as_ref(), key.as_ref())? { copy_hash(cache, &entry.integrity, to) } else { @@ -65,11 +77,19 @@ pub fn copy, K: AsRef>(cache: P, key: K, to: P) -> Result>(cache: P, sri: &Integrity, to: P) -> Result { +pub fn copy_hash(cache: P, sri: &Integrity, to: Q) -> Result +where + P: AsRef, + Q: AsRef, +{ read::copy(cache.as_ref(), sri, to.as_ref()) } -pub fn info, K: AsRef>(cache: P, key: K) -> Result, Error> { +pub fn info(cache: P, key: K) -> Result, Error> +where + P: AsRef, + K: AsRef, +{ index::find(cache.as_ref(), key.as_ref()) }