[go: nahoru, domu]

Skip to content

Commit

Permalink
Unify std::fmt usage & imports (seanmonstar#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickelc authored Sep 13, 2021
1 parent eba6477 commit ab15738
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/filters/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ impl StdError for BodyDeserializeError {
#[derive(Debug)]
pub(crate) struct BodyReadError(::hyper::Error);

impl ::std::fmt::Display for BodyReadError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
impl fmt::Display for BodyReadError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Request body read error: {}", self.0)
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/filters/cors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::collections::HashSet;
use std::convert::TryFrom;
use std::error::Error as StdError;
use std::fmt;
use std::sync::Arc;

use headers::{
Expand Down Expand Up @@ -320,14 +321,14 @@ enum Forbidden {
HeaderNotAllowed,
}

impl ::std::fmt::Debug for CorsForbidden {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
impl fmt::Debug for CorsForbidden {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("CorsForbidden").field(&self.kind).finish()
}
}

impl ::std::fmt::Display for CorsForbidden {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
impl fmt::Display for CorsForbidden {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let detail = match self.kind {
Forbidden::OriginNotAllowed => "origin not allowed",
Forbidden::MethodNotAllowed => "request-method not allowed",
Expand Down
10 changes: 5 additions & 5 deletions src/filters/sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
use serde::Serialize;
use std::borrow::Cow;
use std::error::Error as StdError;
use std::fmt::{self, Display, Formatter, Write};
use std::fmt::{self, Write};
use std::future::Future;
use std::pin::Pin;
use std::str::FromStr;
Expand Down Expand Up @@ -123,8 +123,8 @@ impl Event {
}
}

impl Display for Event {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
impl fmt::Display for Event {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(ref comment) = &self.comment {
":".fmt(f)?;
comment.fmt(f)?;
Expand Down Expand Up @@ -501,8 +501,8 @@ mod sealed {
#[derive(Debug)]
pub struct SseError;

impl Display for SseError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
impl fmt::Display for SseError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "sse error")
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/filters/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ impl From<Message> for Vec<u8> {
#[derive(Debug)]
pub struct MissingConnectionUpgrade;

impl ::std::fmt::Display for MissingConnectionUpgrade {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
impl fmt::Display for MissingConnectionUpgrade {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Connection header did not include 'upgrade'")
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/reject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ impl MissingHeader {
}
}

impl ::std::fmt::Display for MissingHeader {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
impl fmt::Display for MissingHeader {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Missing request header {:?}", self.name)
}
}
Expand All @@ -573,8 +573,8 @@ impl InvalidHeader {
}
}

impl ::std::fmt::Display for InvalidHeader {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
impl fmt::Display for InvalidHeader {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Invalid request header {:?}", self.name)
}
}
Expand All @@ -594,8 +594,8 @@ impl MissingCookie {
}
}

impl ::std::fmt::Display for MissingCookie {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
impl fmt::Display for MissingCookie {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Missing request cookie {:?}", self.name)
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/tls.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fmt;
use std::fs::File;
use std::future::Future;
use std::io::{self, BufReader, Cursor, Read};
Expand Down Expand Up @@ -34,8 +35,8 @@ pub(crate) enum TlsConfigError {
InvalidKey(TLSError),
}

impl std::fmt::Display for TlsConfigError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl fmt::Display for TlsConfigError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TlsConfigError::Io(err) => err.fmt(f),
TlsConfigError::CertParseError => write!(f, "certificate parse error"),
Expand Down Expand Up @@ -67,8 +68,8 @@ pub(crate) struct TlsConfigBuilder {
ocsp_resp: Vec<u8>,
}

impl std::fmt::Debug for TlsConfigBuilder {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
impl fmt::Debug for TlsConfigBuilder {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TlsConfigBuilder").finish()
}
}
Expand Down

0 comments on commit ab15738

Please sign in to comment.