diff --git a/src/header/common/cache_control.rs b/src/header/common/cache_control.rs index 05aef3d80b..8ea6ad253c 100644 --- a/src/header/common/cache_control.rs +++ b/src/header/common/cache_control.rs @@ -72,7 +72,7 @@ pub enum CacheDirective { impl fmt::String for CacheDirective { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use self::CacheDirective::*; - match *self { + fmt::String::fmt(match *self { NoCache => "no-cache", NoStore => "no-store", NoTransform => "no-transform", @@ -91,7 +91,7 @@ impl fmt::String for CacheDirective { Extension(ref name, None) => &name[], Extension(ref name, Some(ref arg)) => return write!(f, "{}={}", name, arg), - }.fmt(f) + }, f) } } diff --git a/src/header/common/connection.rs b/src/header/common/connection.rs index 1a631af85a..809c75ad23 100644 --- a/src/header/common/connection.rs +++ b/src/header/common/connection.rs @@ -1,5 +1,5 @@ use header::{Header, HeaderFormat}; -use std::fmt::{self, Show}; +use std::fmt; use std::str::FromStr; use header::shared::util::{from_comma_delimited, fmt_comma_delimited}; @@ -12,7 +12,7 @@ pub struct Connection(pub Vec); deref!(Connection => Vec); /// Values that can be in the `Connection` header. -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, Show)] pub enum ConnectionOption { /// The `keep-alive` connection value. KeepAlive, @@ -49,12 +49,6 @@ impl fmt::String for ConnectionOption { } } -impl fmt::Show for ConnectionOption { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - self.to_string().fmt(fmt) - } -} - impl Header for Connection { fn header_name(_: Option) -> &'static str { "Connection" diff --git a/src/header/common/content_type.rs b/src/header/common/content_type.rs index cdf9562017..4cc2805ff8 100644 --- a/src/header/common/content_type.rs +++ b/src/header/common/content_type.rs @@ -1,5 +1,5 @@ use header::{Header, HeaderFormat}; -use std::fmt::{self, String}; +use std::fmt; use header::shared::util::from_one_raw_str; use mime::Mime; @@ -24,8 +24,7 @@ impl Header for ContentType { impl HeaderFormat for ContentType { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let ContentType(ref value) = *self; - value.fmt(fmt) + fmt::String::fmt(&self.0, fmt) } } diff --git a/src/header/common/date.rs b/src/header/common/date.rs index 50eb83ef07..d14ad23fed 100644 --- a/src/header/common/date.rs +++ b/src/header/common/date.rs @@ -1,4 +1,4 @@ -use std::fmt::{self, Show}; +use std::fmt; use std::str::FromStr; use time::Tm; use header::{Header, HeaderFormat}; @@ -7,7 +7,7 @@ use header::shared::time::tm_from_str; // Egh, replace as soon as something better than time::Tm exists. /// The `Date` header field. -#[derive(Copy, PartialEq, Clone)] +#[derive(Copy, PartialEq, Clone, Show)] pub struct Date(pub Tm); deref!(Date => Tm); @@ -25,11 +25,12 @@ impl Header for Date { impl HeaderFormat for Date { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let tm = **self; - match tm.tm_utcoff { - 0 => tm.rfc822().fmt(fmt), - _ => tm.to_utc().rfc822().fmt(fmt) - } + let tm = self.0; + let tm = match tm.tm_utcoff { + 0 => tm, + _ => tm.to_utc(), + }; + fmt::String::fmt(&tm.rfc822(), fmt) } } diff --git a/src/header/common/expires.rs b/src/header/common/expires.rs index 782c10d060..eb1ae7f717 100644 --- a/src/header/common/expires.rs +++ b/src/header/common/expires.rs @@ -1,4 +1,4 @@ -use std::fmt::{self, Show}; +use std::fmt; use std::str::FromStr; use time::Tm; use header::{Header, HeaderFormat}; @@ -6,7 +6,7 @@ use header::shared::util::from_one_raw_str; use header::shared::time::tm_from_str; /// The `Expires` header field. -#[derive(Copy, PartialEq, Clone)] +#[derive(Copy, PartialEq, Clone, Show)] pub struct Expires(pub Tm); deref!(Expires => Tm); @@ -24,11 +24,12 @@ impl Header for Expires { impl HeaderFormat for Expires { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let tm = **self; - match tm.tm_utcoff { - 0 => tm.rfc822().fmt(fmt), - _ => tm.to_utc().rfc822().fmt(fmt) - } + let tm = self.0; + let tm = match tm.tm_utcoff { + 0 => tm, + _ => tm.to_utc(), + }; + fmt::String::fmt(&tm.rfc822(), fmt) } } diff --git a/src/header/common/if_modified_since.rs b/src/header/common/if_modified_since.rs index 6090714fc0..f826d385eb 100644 --- a/src/header/common/if_modified_since.rs +++ b/src/header/common/if_modified_since.rs @@ -1,4 +1,4 @@ -use std::fmt::{self, Show}; +use std::fmt; use std::str::FromStr; use time::Tm; use header::{Header, HeaderFormat}; @@ -6,7 +6,7 @@ use header::shared::util::from_one_raw_str; use header::shared::time::tm_from_str; /// The `If-Modified-Since` header field. -#[derive(Copy, PartialEq, Clone)] +#[derive(Copy, PartialEq, Clone, Show)] pub struct IfModifiedSince(pub Tm); deref!(IfModifiedSince => Tm); @@ -24,11 +24,12 @@ impl Header for IfModifiedSince { impl HeaderFormat for IfModifiedSince { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let tm = **self; - match tm.tm_utcoff { - 0 => tm.rfc822().fmt(fmt), - _ => tm.to_utc().rfc822().fmt(fmt) - } + let tm = self.0; + let tm = match tm.tm_utcoff { + 0 => tm, + _ => tm.to_utc(), + }; + fmt::String::fmt(&tm.rfc822(), fmt) } } diff --git a/src/header/common/last_modified.rs b/src/header/common/last_modified.rs index 9b963b6797..2452e7d489 100644 --- a/src/header/common/last_modified.rs +++ b/src/header/common/last_modified.rs @@ -1,4 +1,4 @@ -use std::fmt::{self, Show}; +use std::fmt; use std::str::FromStr; use time::Tm; use header::{Header, HeaderFormat}; @@ -6,7 +6,7 @@ use header::shared::util::from_one_raw_str; use header::shared::time::tm_from_str; /// The `LastModified` header field. -#[derive(Copy, PartialEq, Clone)] +#[derive(Copy, PartialEq, Clone, Show)] pub struct LastModified(pub Tm); deref!(LastModified => Tm); @@ -24,11 +24,12 @@ impl Header for LastModified { impl HeaderFormat for LastModified { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let tm = **self; - match tm.tm_utcoff { - 0 => tm.rfc822().fmt(fmt), - _ => tm.to_utc().rfc822().fmt(fmt) - } + let tm = self.0; + let tm = match tm.tm_utcoff { + 0 => tm, + _ => tm.to_utc(), + }; + fmt::String::fmt(&tm.rfc822(), fmt) } } diff --git a/src/header/common/location.rs b/src/header/common/location.rs index 7541271a08..28197c8037 100644 --- a/src/header/common/location.rs +++ b/src/header/common/location.rs @@ -1,5 +1,5 @@ use header::{Header, HeaderFormat}; -use std::fmt::{self, Show}; +use std::fmt; use header::shared::util::from_one_raw_str; /// The `Location` header. @@ -30,8 +30,7 @@ impl Header for Location { impl HeaderFormat for Location { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let Location(ref value) = *self; - value.fmt(fmt) + fmt.write_str(&*self.0) } } diff --git a/src/header/common/server.rs b/src/header/common/server.rs index 170f8597e9..dcc55e000e 100644 --- a/src/header/common/server.rs +++ b/src/header/common/server.rs @@ -1,5 +1,5 @@ use header::{Header, HeaderFormat}; -use std::fmt::{self, Show}; +use std::fmt; use header::shared::util::from_one_raw_str; /// The `Server` header field. @@ -22,8 +22,7 @@ impl Header for Server { impl HeaderFormat for Server { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let Server(ref value) = *self; - value.fmt(fmt) + fmt.write_str(&*self.0) } } diff --git a/src/header/common/transfer_encoding.rs b/src/header/common/transfer_encoding.rs index 4edddf216e..625c1b3c0b 100644 --- a/src/header/common/transfer_encoding.rs +++ b/src/header/common/transfer_encoding.rs @@ -33,7 +33,7 @@ deref!(TransferEncoding => Vec); /// # use hyper::header::Headers; /// # let mut headers = Headers::new(); /// headers.set(TransferEncoding(vec![Gzip, Chunked])); -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, Show)] pub enum Encoding { /// The `chunked` encoding. Chunked, @@ -59,12 +59,6 @@ impl fmt::String for Encoding { } } -impl fmt::Show for Encoding { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - self.to_string().fmt(fmt) - } -} - impl FromStr for Encoding { fn from_str(s: &str) -> Option { match s { diff --git a/src/header/common/upgrade.rs b/src/header/common/upgrade.rs index 31635a19ec..979737802c 100644 --- a/src/header/common/upgrade.rs +++ b/src/header/common/upgrade.rs @@ -1,5 +1,5 @@ use header::{Header, HeaderFormat}; -use std::fmt::{self, Show}; +use std::fmt; use std::str::FromStr; use header::shared::util::{from_comma_delimited, fmt_comma_delimited}; @@ -12,7 +12,7 @@ pub struct Upgrade(pub Vec); deref!(Upgrade => Vec); /// Protocol values that can appear in the Upgrade header. -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, Show)] pub enum Protocol { /// The websocket protocol. WebSocket, @@ -38,12 +38,6 @@ impl fmt::String for Protocol { } } -impl fmt::Show for Protocol { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - self.to_string().fmt(fmt) - } -} - impl Header for Upgrade { fn header_name(_: Option) -> &'static str { "Upgrade"