diff --git a/ruma-client-api/src/error.rs b/ruma-client-api/src/error.rs index 907ccbfa..01fce172 100644 --- a/ruma-client-api/src/error.rs +++ b/ruma-client-api/src/error.rs @@ -1,10 +1,6 @@ //! Errors that can be sent from the homeserver. -use std::{ - collections::BTreeMap, - fmt::{self, Display, Formatter}, - time::Duration, -}; +use std::{collections::BTreeMap, fmt, time::Duration}; use ruma_api::{error::ResponseDeserializationError, EndpointError}; use ruma_identifiers::RoomVersionId; @@ -173,8 +169,8 @@ impl AsRef for ErrorKind { } } -impl Display for ErrorKind { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Display for ErrorKind { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.as_ref()) } } @@ -216,8 +212,8 @@ impl EndpointError for Error { } } -impl Display for Error { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[{} / {}] {}", self.status_code.as_u16(), self.kind, self.message) } } diff --git a/ruma-client-api/src/r0/push.rs b/ruma-client-api/src/r0/push.rs index 6e0148ee..e46ce2f3 100644 --- a/ruma-client-api/src/r0/push.rs +++ b/ruma-client-api/src/r0/push.rs @@ -1,9 +1,5 @@ //! Endpoints for push notifications. -use std::{ - convert::TryFrom, - error::Error, - fmt::{self, Display, Formatter}, -}; +use std::{convert::TryFrom, error::Error, fmt}; use ruma_common::push::{ Action, ConditionalPushRule, ConditionalPushRuleInit, PatternedPushRule, PatternedPushRuleInit, @@ -111,8 +107,8 @@ impl From for SimplePushRule { #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct MissingPatternError; -impl Display for MissingPatternError { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { +impl fmt::Display for MissingPatternError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Push rule does not have a pattern.") } } @@ -139,8 +135,8 @@ impl TryFrom for PatternedPushRule { #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct MissingConditionsError; -impl Display for MissingConditionsError { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { +impl fmt::Display for MissingConditionsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Push rule has no conditions.") } } diff --git a/ruma-client-api/src/r0/uiaa.rs b/ruma-client-api/src/r0/uiaa.rs index 644291b7..e7891fbf 100644 --- a/ruma-client-api/src/r0/uiaa.rs +++ b/ruma-client-api/src/r0/uiaa.rs @@ -1,9 +1,6 @@ //! Module for User-Interactive Authentication API types. -use std::{ - collections::BTreeMap, - fmt::{self, Display, Formatter}, -}; +use std::{collections::BTreeMap, fmt}; use ruma_api::{error::ResponseDeserializationError, EndpointError}; use ruma_serde::Outgoing; @@ -120,8 +117,8 @@ pub enum UiaaResponse { MatrixError(MatrixError), } -impl Display for UiaaResponse { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Display for UiaaResponse { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::AuthResponse(_) => write!(f, "User-Interactive Authentication required."), Self::MatrixError(err) => write!(f, "{}", err), diff --git a/ruma-common/src/push/condition/room_member_count_is.rs b/ruma-common/src/push/condition/room_member_count_is.rs index 743e3b09..b03439f9 100644 --- a/ruma-common/src/push/condition/room_member_count_is.rs +++ b/ruma-common/src/push/condition/room_member_count_is.rs @@ -1,5 +1,5 @@ use std::{ - fmt::{self, Display, Formatter}, + fmt, ops::{Bound, RangeBounds, RangeFrom, RangeTo, RangeToInclusive}, str::FromStr, }; @@ -101,8 +101,8 @@ impl From> for RoomMemberCountIs { } } -impl Display for RoomMemberCountIs { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Display for RoomMemberCountIs { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use ComparisonOperator as Op; let prefix = match self.prefix { diff --git a/ruma-events/src/error.rs b/ruma-events/src/error.rs index f446db05..5909788b 100644 --- a/ruma-events/src/error.rs +++ b/ruma-events/src/error.rs @@ -1,7 +1,4 @@ -use std::{ - error::Error, - fmt::{self, Display, Formatter}, -}; +use std::{error::Error, fmt}; /// An error returned when attempting to create an event with data that would make it invalid. /// @@ -10,8 +7,8 @@ use std::{ #[derive(Clone, Debug, PartialEq)] pub struct InvalidInput(pub(crate) String); -impl Display for InvalidInput { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Display for InvalidInput { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.0) } } @@ -22,8 +19,8 @@ impl Error for InvalidInput {} #[derive(Clone, Eq, Debug, Hash, PartialEq)] pub struct FromStrError; -impl Display for FromStrError { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Display for FromStrError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "failed to parse type from string") } } diff --git a/ruma-identifiers-validation/src/error.rs b/ruma-identifiers-validation/src/error.rs index 771f509c..a6a2801f 100644 --- a/ruma-identifiers-validation/src/error.rs +++ b/ruma-identifiers-validation/src/error.rs @@ -1,6 +1,6 @@ //! Error conditions. -use std::fmt::{self, Display, Formatter}; +use std::fmt; /// An error encountered when trying to parse an invalid ID string. #[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)] @@ -36,8 +36,8 @@ pub enum Error { MissingLeadingSigil, } -impl Display for Error { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let message = match self { Error::EmptyRoomVersionId => "room version ID is empty", Error::InvalidCharacters => "localpart contains invalid characters", diff --git a/ruma-identifiers/src/mxc_uri.rs b/ruma-identifiers/src/mxc_uri.rs index 485c4543..c90173ef 100644 --- a/ruma-identifiers/src/mxc_uri.rs +++ b/ruma-identifiers/src/mxc_uri.rs @@ -1,10 +1,6 @@ //! Matrix-spec compliant mxc:// urls. -use std::{ - convert::TryFrom, - fmt::{self, Display}, - str::FromStr, -}; +use std::{convert::TryFrom, fmt, str::FromStr}; use ruma_identifiers_validation::mxc_uri::validate; @@ -39,7 +35,7 @@ impl fmt::Debug for MxcUri { } } -impl Display for MxcUri { +impl fmt::Display for MxcUri { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.mxc_uri_fmt(f) } diff --git a/ruma-identifiers/src/server_name.rs b/ruma-identifiers/src/server_name.rs index fc6dde35..ae5c6296 100644 --- a/ruma-identifiers/src/server_name.rs +++ b/ruma-identifiers/src/server_name.rs @@ -1,11 +1,6 @@ //! Matrix-spec compliant server names. -use std::{ - convert::TryFrom, - fmt::{self, Display}, - mem, - str::FromStr, -}; +use std::{convert::TryFrom, fmt, mem, str::FromStr}; use ruma_identifiers_validation::server_name::validate; @@ -130,7 +125,7 @@ impl TryFrom for Box { } } -impl Display for ServerName { +impl fmt::Display for ServerName { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.as_str()) }