Skip to content

Commit ab15738

Browse files
authored
Unify std::fmt usage & imports (#899)
1 parent eba6477 commit ab15738

File tree

6 files changed

+25
-23
lines changed

6 files changed

+25
-23
lines changed

src/filters/body.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ impl StdError for BodyDeserializeError {
332332
#[derive(Debug)]
333333
pub(crate) struct BodyReadError(::hyper::Error);
334334

335-
impl ::std::fmt::Display for BodyReadError {
336-
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
335+
impl fmt::Display for BodyReadError {
336+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
337337
write!(f, "Request body read error: {}", self.0)
338338
}
339339
}

src/filters/cors.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::collections::HashSet;
44
use std::convert::TryFrom;
55
use std::error::Error as StdError;
6+
use std::fmt;
67
use std::sync::Arc;
78

89
use headers::{
@@ -320,14 +321,14 @@ enum Forbidden {
320321
HeaderNotAllowed,
321322
}
322323

323-
impl ::std::fmt::Debug for CorsForbidden {
324-
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
324+
impl fmt::Debug for CorsForbidden {
325+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
325326
f.debug_tuple("CorsForbidden").field(&self.kind).finish()
326327
}
327328
}
328329

329-
impl ::std::fmt::Display for CorsForbidden {
330-
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
330+
impl fmt::Display for CorsForbidden {
331+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
331332
let detail = match self.kind {
332333
Forbidden::OriginNotAllowed => "origin not allowed",
333334
Forbidden::MethodNotAllowed => "request-method not allowed",

src/filters/sse.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
use serde::Serialize;
4343
use std::borrow::Cow;
4444
use std::error::Error as StdError;
45-
use std::fmt::{self, Display, Formatter, Write};
45+
use std::fmt::{self, Write};
4646
use std::future::Future;
4747
use std::pin::Pin;
4848
use std::str::FromStr;
@@ -123,8 +123,8 @@ impl Event {
123123
}
124124
}
125125

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

504-
impl Display for SseError {
505-
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
504+
impl fmt::Display for SseError {
505+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
506506
write!(f, "sse error")
507507
}
508508
}

src/filters/ws.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ impl From<Message> for Vec<u8> {
400400
#[derive(Debug)]
401401
pub struct MissingConnectionUpgrade;
402402

403-
impl ::std::fmt::Display for MissingConnectionUpgrade {
404-
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
403+
impl fmt::Display for MissingConnectionUpgrade {
404+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
405405
write!(f, "Connection header did not include 'upgrade'")
406406
}
407407
}

src/reject.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ impl MissingHeader {
552552
}
553553
}
554554

555-
impl ::std::fmt::Display for MissingHeader {
556-
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
555+
impl fmt::Display for MissingHeader {
556+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
557557
write!(f, "Missing request header {:?}", self.name)
558558
}
559559
}
@@ -573,8 +573,8 @@ impl InvalidHeader {
573573
}
574574
}
575575

576-
impl ::std::fmt::Display for InvalidHeader {
577-
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
576+
impl fmt::Display for InvalidHeader {
577+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
578578
write!(f, "Invalid request header {:?}", self.name)
579579
}
580580
}
@@ -594,8 +594,8 @@ impl MissingCookie {
594594
}
595595
}
596596

597-
impl ::std::fmt::Display for MissingCookie {
598-
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
597+
impl fmt::Display for MissingCookie {
598+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
599599
write!(f, "Missing request cookie {:?}", self.name)
600600
}
601601
}

src/tls.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::fmt;
12
use std::fs::File;
23
use std::future::Future;
34
use std::io::{self, BufReader, Cursor, Read};
@@ -34,8 +35,8 @@ pub(crate) enum TlsConfigError {
3435
InvalidKey(TLSError),
3536
}
3637

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

70-
impl std::fmt::Debug for TlsConfigBuilder {
71-
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
71+
impl fmt::Debug for TlsConfigBuilder {
72+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
7273
f.debug_struct("TlsConfigBuilder").finish()
7374
}
7475
}

0 commit comments

Comments
 (0)