From 85f152fcccc8c237d4ad44e7188693ccf20a2eb2 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 9 Apr 2021 12:51:50 +0200 Subject: [PATCH] api: Normalize std::fmt import --- ruma-api/src/error.rs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/ruma-api/src/error.rs b/ruma-api/src/error.rs index fd29148b..9f2046f2 100644 --- a/ruma-api/src/error.rs +++ b/ruma-api/src/error.rs @@ -2,10 +2,7 @@ //! converting between http requests / responses and ruma's representation of //! matrix API requests / responses. -use std::{ - error::Error as StdError, - fmt::{self, Debug, Display, Formatter}, -}; +use std::{error::Error as StdError, fmt}; use thiserror::Error; @@ -24,7 +21,7 @@ impl EndpointError for Void { } } -impl Display for Void { +impl fmt::Display for Void { fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result { match *self {} } @@ -100,8 +97,8 @@ pub enum FromHttpResponseError { Http(ServerError), } -impl Display for FromHttpResponseError { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Display for FromHttpResponseError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Deserialization(err) => write!(f, "deserialization failed: {}", err), Self::Http(err) => write!(f, "the server returned an error: {}", err), @@ -146,12 +143,12 @@ impl ResponseDeserializationError { } } -impl Display for ResponseDeserializationError { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Display for ResponseDeserializationError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(ref inner) = self.inner { - Display::fmt(inner, f) + fmt::Display::fmt(inner, f) } else { - Display::fmt("deserialization error, no error specified", f) + fmt::Display::fmt("deserialization error, no error specified", f) } } } @@ -169,11 +166,11 @@ pub enum ServerError { Unknown(ResponseDeserializationError), } -impl Display for ServerError { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Display for ServerError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - ServerError::Known(e) => Display::fmt(e, f), - ServerError::Unknown(res_err) => Display::fmt(res_err, f), + ServerError::Known(e) => fmt::Display::fmt(e, f), + ServerError::Unknown(res_err) => fmt::Display::fmt(res_err, f), } } }