Clean up std::fmt imports

We were pretty inconsistent about them before.
This commit is contained in:
Jonas Platte 2021-03-25 16:32:08 +01:00
parent f053200462
commit 12686fe6e3
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
8 changed files with 28 additions and 51 deletions

View File

@ -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<str> 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)
}
}

View File

@ -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<PushRule> 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<PushRule> 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.")
}
}

View File

@ -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),

View File

@ -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<RangeToInclusive<UInt>> 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 {

View File

@ -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")
}
}

View File

@ -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",

View File

@ -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)
}

View File

@ -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<String> for Box<ServerName> {
}
}
impl Display for ServerName {
impl fmt::Display for ServerName {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.as_str())
}