fix clippy warnings on api

This commit is contained in:
Trinity Pointard
2021-04-23 22:18:00 +02:00
committed by Alex Auvolat
parent 4a1e079e8f
commit 84856e84e5
8 changed files with 85 additions and 81 deletions
+5 -5
View File
@@ -8,6 +8,7 @@ use garage_util::error::Error as GarageError;
use crate::encoding::*;
/// Errors of this crate
#[allow(clippy::upper_case_acronyms)]
#[derive(Debug, Error)]
pub enum Error {
// Category: internal error
@@ -140,7 +141,7 @@ impl<T> OkOrBadRequest for Option<T> {
fn ok_or_bad_request(self, reason: &'static str) -> Result<T, Error> {
match self {
Some(x) => Ok(x),
None => Err(Error::BadRequest(format!("{}", reason))),
None => Err(Error::BadRequest(reason.to_string())),
}
}
}
@@ -172,10 +173,9 @@ impl<T> OkOrInternalError for Option<T> {
fn ok_or_internal_error(self, reason: &'static str) -> Result<T, Error> {
match self {
Some(x) => Ok(x),
None => Err(Error::InternalError(GarageError::Message(format!(
"{}",
reason
)))),
None => Err(Error::InternalError(GarageError::Message(
reason.to_string(),
))),
}
}
}