diff --git a/benches/client.rs b/benches/client.rs index d53e1c3858..28257428f1 100644 --- a/benches/client.rs +++ b/benches/client.rs @@ -3,7 +3,7 @@ extern crate hyper; extern crate test; -use std::fmt::{self, Show}; +use std::fmt; use std::io::net::ip::Ipv4Addr; use hyper::server::{Request, Response, Server}; use hyper::header::Headers; @@ -44,7 +44,7 @@ impl hyper::header::Header for Foo { impl hyper::header::HeaderFormat for Foo { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - "Bar".fmt(fmt) + fmt.write_str("Bar") } } diff --git a/benches/client_mock_tcp.rs b/benches/client_mock_tcp.rs index 60f2a04bbe..6e7b375ff9 100644 --- a/benches/client_mock_tcp.rs +++ b/benches/client_mock_tcp.rs @@ -3,7 +3,7 @@ extern crate hyper; extern crate test; -use std::fmt::{self, Show}; +use std::fmt; use std::io::{IoResult, MemReader}; use std::io::net::ip::SocketAddr; @@ -60,7 +60,7 @@ impl hyper::header::Header for Foo { impl hyper::header::HeaderFormat for Foo { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - "Bar".fmt(fmt) + fmt.write_str("Bar") } } diff --git a/src/header/common/accept.rs b/src/header/common/accept.rs index 60c5fd50b4..1e6f0f002a 100644 --- a/src/header/common/accept.rs +++ b/src/header/common/accept.rs @@ -25,7 +25,7 @@ use mime; /// qitem(Mime(Text, Html, vec![])), /// qitem(Mime(Text, Xml, vec![])) ])); /// ``` -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct Accept(pub Vec>); deref!(Accept => Vec>); diff --git a/src/header/common/accept_encoding.rs b/src/header/common/accept_encoding.rs index a67bf8c0b7..7399d25c1f 100644 --- a/src/header/common/accept_encoding.rs +++ b/src/header/common/accept_encoding.rs @@ -4,7 +4,7 @@ use header::{self, Encoding, QualityItem}; /// /// The `Accept-Encoding` header can be used by clients to indicate what /// response encodings they accept. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct AcceptEncoding(pub Vec>); impl_list_header!(AcceptEncoding, diff --git a/src/header/common/allow.rs b/src/header/common/allow.rs index d0ee26de83..57c1234fd9 100644 --- a/src/header/common/allow.rs +++ b/src/header/common/allow.rs @@ -6,7 +6,7 @@ use header::parsing::{from_comma_delimited, fmt_comma_delimited}; /// The `Allow` header. /// See also https://tools.ietf.org/html/rfc7231#section-7.4.1 -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct Allow(pub Vec); deref!(Allow => Vec); diff --git a/src/header/common/authorization.rs b/src/header/common/authorization.rs index 6b40599057..74d66f29c5 100644 --- a/src/header/common/authorization.rs +++ b/src/header/common/authorization.rs @@ -5,7 +5,7 @@ use serialize::base64::{ToBase64, FromBase64, Standard, Config, Newline}; use header::{Header, HeaderFormat}; /// The `Authorization` header field. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct Authorization(pub S); impl Deref for Authorization { @@ -75,7 +75,7 @@ impl Scheme for String { } /// Credential holder for Basic Authentication -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct Basic { /// The username as a possibly empty string pub username: String, @@ -90,7 +90,7 @@ impl Scheme for Basic { } fn fmt_scheme(&self, f: &mut fmt::Formatter) -> fmt::Result { - //FIXME: serialize::base64 could use some Show implementation, so + //FIXME: serialize::base64 could use some Debug implementation, so //that we don't have to allocate a new string here just to write it //to the formatter. let mut text = self.username.clone(); diff --git a/src/header/common/cache_control.rs b/src/header/common/cache_control.rs index 930e939aab..f49ea5ccc9 100644 --- a/src/header/common/cache_control.rs +++ b/src/header/common/cache_control.rs @@ -4,7 +4,7 @@ use header::{Header, HeaderFormat}; use header::parsing::{from_one_comma_delimited, fmt_comma_delimited}; /// The Cache-Control header. -#[derive(PartialEq, Clone, Show)] +#[derive(PartialEq, Clone, Debug)] pub struct CacheControl(pub Vec); deref!(CacheControl => Vec); @@ -34,7 +34,7 @@ impl HeaderFormat for CacheControl { } /// CacheControl contains a list of these directives. -#[derive(PartialEq, Clone, Show)] +#[derive(PartialEq, Clone, Debug)] pub enum CacheDirective { /// "no-cache" NoCache, @@ -69,10 +69,10 @@ pub enum CacheDirective { Extension(String, Option) } -impl fmt::String for CacheDirective { +impl fmt::Display for CacheDirective { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use self::CacheDirective::*; - fmt::String::fmt(match *self { + fmt::Display::fmt(match *self { NoCache => "no-cache", NoStore => "no-store", NoTransform => "no-transform", diff --git a/src/header/common/connection.rs b/src/header/common/connection.rs index 6d9b20c74a..5820c88d17 100644 --- a/src/header/common/connection.rs +++ b/src/header/common/connection.rs @@ -6,13 +6,13 @@ use header::parsing::{from_comma_delimited, fmt_comma_delimited}; pub use self::ConnectionOption::{KeepAlive, Close, ConnectionHeader}; /// The `Connection` header. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct Connection(pub Vec); deref!(Connection => Vec); /// Values that can be in the `Connection` header. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub enum ConnectionOption { /// The `keep-alive` connection value. KeepAlive, @@ -39,7 +39,7 @@ impl FromStr for ConnectionOption { } } -impl fmt::String for ConnectionOption { +impl fmt::Display for ConnectionOption { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { write!(fmt, "{}", match *self { KeepAlive => "keep-alive", diff --git a/src/header/common/content_length.rs b/src/header/common/content_length.rs index 499f86adac..4038d49728 100644 --- a/src/header/common/content_length.rs +++ b/src/header/common/content_length.rs @@ -6,7 +6,7 @@ use header::parsing::from_one_raw_str; /// The `Content-Length` header. /// /// Simply a wrapper around a `usize`. -#[derive(Copy, Clone, PartialEq, Show)] +#[derive(Copy, Clone, PartialEq, Debug)] pub struct ContentLength(pub u64); deref!(ContentLength => u64); @@ -23,7 +23,7 @@ impl Header for ContentLength { impl HeaderFormat for ContentLength { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt::String::fmt(&self.0, fmt) + fmt::Display::fmt(&self.0, fmt) } } diff --git a/src/header/common/content_type.rs b/src/header/common/content_type.rs index ef3f0a6228..27d1e3dcf9 100644 --- a/src/header/common/content_type.rs +++ b/src/header/common/content_type.rs @@ -7,7 +7,7 @@ use mime::Mime; /// /// Used to describe the MIME type of message body. Can be used with both /// requests and responses. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct ContentType(pub Mime); deref!(ContentType => Mime); @@ -24,7 +24,7 @@ impl Header for ContentType { impl HeaderFormat for ContentType { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt::String::fmt(&self.0, fmt) + fmt::Display::fmt(&self.0, fmt) } } diff --git a/src/header/common/cookie.rs b/src/header/common/cookie.rs index 8ff6bb36b1..c371bfdc96 100644 --- a/src/header/common/cookie.rs +++ b/src/header/common/cookie.rs @@ -13,7 +13,7 @@ use cookie::CookieJar; /// /// > When the user agent generates an HTTP request, the user agent MUST NOT /// > attach more than one Cookie header field. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct Cookies(pub Vec); deref!(Cookies => Vec); @@ -53,7 +53,7 @@ impl HeaderFormat for Cookies { let last = cookies.len() - 1; for (i, cookie) in cookies.iter().enumerate() { try!(write!(fmt, "{}", cookie.pair())); - if i < last { + if i < last { try!(fmt.write_str("; ")); } } diff --git a/src/header/common/date.rs b/src/header/common/date.rs index 788daeaa13..28e7ad5bdf 100644 --- a/src/header/common/date.rs +++ b/src/header/common/date.rs @@ -7,7 +7,7 @@ use header::parsing::tm_from_str; // Egh, replace as soon as something better than time::Tm exists. /// The `Date` header field. -#[derive(Copy, PartialEq, Clone, Show)] +#[derive(Copy, PartialEq, Clone, Debug)] pub struct Date(pub Tm); deref!(Date => Tm); @@ -30,7 +30,7 @@ impl HeaderFormat for Date { 0 => tm, _ => tm.to_utc(), }; - fmt::String::fmt(&tm.rfc822(), fmt) + fmt::Display::fmt(&tm.rfc822(), fmt) } } diff --git a/src/header/common/etag.rs b/src/header/common/etag.rs index bea55dbdb5..4bf93abef5 100644 --- a/src/header/common/etag.rs +++ b/src/header/common/etag.rs @@ -8,7 +8,7 @@ use header::parsing::from_one_raw_str; /// Preceding the first double quote is an optional weakness indicator, /// which always looks like this: W/ /// See also: https://tools.ietf.org/html/rfc7232#section-2.3 -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct Etag { /// Weakness indicator for the tag pub weak: bool, diff --git a/src/header/common/expires.rs b/src/header/common/expires.rs index af3a5f9823..7878326da4 100644 --- a/src/header/common/expires.rs +++ b/src/header/common/expires.rs @@ -6,7 +6,7 @@ use header::parsing::from_one_raw_str; use header::parsing::tm_from_str; /// The `Expires` header field. -#[derive(Copy, PartialEq, Clone, Show)] +#[derive(Copy, PartialEq, Clone, Debug)] pub struct Expires(pub Tm); deref!(Expires => Tm); @@ -29,7 +29,7 @@ impl HeaderFormat for Expires { 0 => tm, _ => tm.to_utc(), }; - fmt::String::fmt(&tm.rfc822(), fmt) + fmt::Display::fmt(&tm.rfc822(), fmt) } } diff --git a/src/header/common/host.rs b/src/header/common/host.rs index 57956f1d12..2e0a167cb7 100644 --- a/src/header/common/host.rs +++ b/src/header/common/host.rs @@ -10,7 +10,7 @@ use header::parsing::from_one_raw_str; /// /// Currently is just a String, but it should probably become a better type, /// like url::Host or something. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct Host { /// The hostname, such a example.domain. pub hostname: String, @@ -46,7 +46,7 @@ impl Header for Host { }; let port = match idx { - Some(idx) => s[].slice_from(idx + 1).parse(), + Some(idx) => s[idx + 1..].parse(), None => None }; diff --git a/src/header/common/if_modified_since.rs b/src/header/common/if_modified_since.rs index b7de8ebc5e..e9d78be38e 100644 --- a/src/header/common/if_modified_since.rs +++ b/src/header/common/if_modified_since.rs @@ -6,7 +6,7 @@ use header::parsing::from_one_raw_str; use header::parsing::tm_from_str; /// The `If-Modified-Since` header field. -#[derive(Copy, PartialEq, Clone, Show)] +#[derive(Copy, PartialEq, Clone, Debug)] pub struct IfModifiedSince(pub Tm); deref!(IfModifiedSince => Tm); @@ -29,7 +29,7 @@ impl HeaderFormat for IfModifiedSince { 0 => tm, _ => tm.to_utc(), }; - fmt::String::fmt(&tm.rfc822(), fmt) + fmt::Display::fmt(&tm.rfc822(), fmt) } } diff --git a/src/header/common/last_modified.rs b/src/header/common/last_modified.rs index 9c43adaea8..e44b447d54 100644 --- a/src/header/common/last_modified.rs +++ b/src/header/common/last_modified.rs @@ -6,7 +6,7 @@ use header::parsing::from_one_raw_str; use header::parsing::tm_from_str; /// The `LastModified` header field. -#[derive(Copy, PartialEq, Clone, Show)] +#[derive(Copy, PartialEq, Clone, Debug)] pub struct LastModified(pub Tm); deref!(LastModified => Tm); @@ -29,7 +29,7 @@ impl HeaderFormat for LastModified { 0 => tm, _ => tm.to_utc(), }; - fmt::String::fmt(&tm.rfc822(), fmt) + fmt::Display::fmt(&tm.rfc822(), fmt) } } diff --git a/src/header/common/location.rs b/src/header/common/location.rs index d964b6ba14..3397fb74ae 100644 --- a/src/header/common/location.rs +++ b/src/header/common/location.rs @@ -13,7 +13,7 @@ use header::parsing::from_one_raw_str; /// /// Currently is just a String, but it should probably become a better type, /// like url::Url or something. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct Location(pub String); deref!(Location => String); diff --git a/src/header/common/mod.rs b/src/header/common/mod.rs index 6a62848dfe..372460d53c 100644 --- a/src/header/common/mod.rs +++ b/src/header/common/mod.rs @@ -101,7 +101,7 @@ macro_rules! impl_list_header( } } - impl ::std::fmt::String for $from { + impl ::std::fmt::Display for $from { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { use header::HeaderFormat; self.fmt_header(f) @@ -127,11 +127,11 @@ macro_rules! impl_header( impl header::HeaderFormat for $from { fn fmt_header(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::std::fmt::String::fmt(&**self, f) + ::std::fmt::Display::fmt(&**self, f) } } - impl ::std::fmt::String for $from { + impl ::std::fmt::Display for $from { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { use header::HeaderFormat; self.fmt_header(f) diff --git a/src/header/common/referer.rs b/src/header/common/referer.rs index af73645605..873deebe91 100644 --- a/src/header/common/referer.rs +++ b/src/header/common/referer.rs @@ -1,5 +1,5 @@ use header::{Header, HeaderFormat}; -use std::fmt::{self, Show}; +use std::fmt; use header::parsing::from_one_raw_str; /// The `Referer` header. @@ -10,7 +10,7 @@ use header::parsing::from_one_raw_str; /// See alse [RFC 1945, section 10.13](http://tools.ietf.org/html/rfc1945#section-10.13). /// /// Currently just a string, but maybe better replace it with url::Url or something like it. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct Referer(pub String); deref!(Referer => String); @@ -27,8 +27,7 @@ impl Header for Referer { impl HeaderFormat for Referer { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let Referer(ref value) = *self; - value.fmt(fmt) + fmt::Display::fmt(&self.0, fmt) } } diff --git a/src/header/common/server.rs b/src/header/common/server.rs index d48f800c80..1a649296c0 100644 --- a/src/header/common/server.rs +++ b/src/header/common/server.rs @@ -3,7 +3,7 @@ use header; /// The `Server` header field. /// /// They can contain any value, so it just wraps a `String`. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct Server(pub String); impl_header!(Server, diff --git a/src/header/common/set_cookie.rs b/src/header/common/set_cookie.rs index 2900428ffe..436fc98ca8 100644 --- a/src/header/common/set_cookie.rs +++ b/src/header/common/set_cookie.rs @@ -10,7 +10,7 @@ use cookie::CookieJar; /// Informally, the Set-Cookie response header contains the header name /// "Set-Cookie" followed by a ":" and a cookie. Each cookie begins with /// a name-value-pair, followed by zero or more attribute-value pairs. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct SetCookie(pub Vec); deref!(SetCookie => Vec); diff --git a/src/header/common/transfer_encoding.rs b/src/header/common/transfer_encoding.rs index 79ad1b0a0a..ccad76d2b7 100644 --- a/src/header/common/transfer_encoding.rs +++ b/src/header/common/transfer_encoding.rs @@ -16,7 +16,7 @@ use header::parsing::{from_comma_delimited, fmt_comma_delimited}; /// this header should include `chunked` as the last encoding. /// /// The implementation uses a vector of `Encoding` values. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct TransferEncoding(pub Vec); deref!(TransferEncoding => Vec); diff --git a/src/header/common/upgrade.rs b/src/header/common/upgrade.rs index 71996c40e6..b3f03f83a4 100644 --- a/src/header/common/upgrade.rs +++ b/src/header/common/upgrade.rs @@ -6,13 +6,13 @@ use header::parsing::{from_comma_delimited, fmt_comma_delimited}; use self::Protocol::{WebSocket, ProtocolExt}; /// The `Upgrade` header. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct Upgrade(pub Vec); deref!(Upgrade => Vec); /// Protocol values that can appear in the Upgrade header. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub enum Protocol { /// The websocket protocol. WebSocket, @@ -29,7 +29,7 @@ impl FromStr for Protocol { } } -impl fmt::String for Protocol { +impl fmt::Display for Protocol { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { write!(fmt, "{}", match *self { WebSocket => "websocket", diff --git a/src/header/common/user_agent.rs b/src/header/common/user_agent.rs index e2230904fb..38ed8186b8 100644 --- a/src/header/common/user_agent.rs +++ b/src/header/common/user_agent.rs @@ -5,7 +5,7 @@ use header::parsing::from_one_raw_str; /// The `User-Agent` header field. /// /// They can contain any value, so it just wraps a `String`. -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub struct UserAgent(pub String); deref!(UserAgent => String); diff --git a/src/header/common/vary.rs b/src/header/common/vary.rs index c91065995f..52482e7359 100644 --- a/src/header/common/vary.rs +++ b/src/header/common/vary.rs @@ -6,7 +6,7 @@ use unicase::UniCase; /// The `Allow` header. /// See also https://tools.ietf.org/html/rfc7231#section-7.1.4 -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, PartialEq, Debug)] pub enum Vary { /// This corresponds to '*'. Any, diff --git a/src/header/mod.rs b/src/header/mod.rs index bd4c9fa855..0476952f9d 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -267,7 +267,7 @@ impl Headers { } } -impl fmt::String for Headers { +impl fmt::Display for Headers { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { for header in self.iter() { try!(write!(fmt, "{}\r\n", header)); @@ -276,7 +276,7 @@ impl fmt::String for Headers { } } -impl fmt::Show for Headers { +impl fmt::Debug for Headers { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { try!(fmt.write_str("Headers {{ ")); for header in self.iter() { @@ -336,15 +336,15 @@ impl<'a> HeaderView<'a> { } } -impl<'a> fmt::String for HeaderView<'a> { +impl<'a> fmt::Display for HeaderView<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}: {}", self.0, *self.1.borrow()) } } -impl<'a> fmt::Show for HeaderView<'a> { +impl<'a> fmt::Debug for HeaderView<'a> { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - self.to_string().fmt(fmt) + fmt::Display::fmt(self, fmt) } } @@ -448,7 +448,7 @@ unsafe fn downcast_mut(item: &mut Item) -> &mut H { item.typed.as_mut().expect("item.typed must be set").downcast_mut_unchecked() } -impl fmt::String for Item { +impl fmt::Display for Item { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match self.typed { Some(ref h) => h.fmt_header(fmt), @@ -472,13 +472,13 @@ impl fmt::String for Item { } -impl fmt::Show for Box { +impl fmt::Debug for Box { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { (**self).fmt_header(fmt) } } -impl fmt::String for Box { +impl fmt::Display for Box { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { (**self).fmt_header(fmt) } @@ -491,13 +491,13 @@ impl fmt::String for Box { /// outgoing TcpStream. pub struct HeaderFormatter<'a, H: HeaderFormat>(pub &'a H); -impl<'a, H: HeaderFormat> fmt::String for HeaderFormatter<'a, H> { +impl<'a, H: HeaderFormat> fmt::Display for HeaderFormatter<'a, H> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.0.fmt_header(f) } } -impl<'a, H: HeaderFormat> fmt::Show for HeaderFormatter<'a, H> { +impl<'a, H: HeaderFormat> fmt::Debug for HeaderFormatter<'a, H> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.0.fmt_header(f) } diff --git a/src/header/parsing.rs b/src/header/parsing.rs index d42fde3285..940fd1a583 100644 --- a/src/header/parsing.rs +++ b/src/header/parsing.rs @@ -42,7 +42,7 @@ pub fn from_one_comma_delimited(raw: &[u8]) -> Option> { } /// Format an array into a comma-delimited string. -pub fn fmt_comma_delimited(fmt: &mut fmt::Formatter, parts: &[T]) -> fmt::Result { +pub fn fmt_comma_delimited(fmt: &mut fmt::Formatter, parts: &[T]) -> fmt::Result { let last = parts.len() - 1; for (i, part) in parts.iter().enumerate() { try!(write!(fmt, "{}", part)); diff --git a/src/header/shared/encoding.rs b/src/header/shared/encoding.rs index d50c463537..8a20447ad6 100644 --- a/src/header/shared/encoding.rs +++ b/src/header/shared/encoding.rs @@ -7,7 +7,7 @@ pub use self::Encoding::{Chunked, Gzip, Deflate, Compress, Identity, EncodingExt /// A value to represent an encoding used in `Transfer-Encoding` /// or `Accept-Encoding` header. -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, Debug)] pub enum Encoding { /// The `chunked` encoding. Chunked, @@ -23,9 +23,9 @@ pub enum Encoding { EncodingExt(String) } -impl fmt::String for Encoding { +impl fmt::Display for Encoding { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "{}", match *self { + fmt.write_str(match *self { Chunked => "chunked", Gzip => "gzip", Deflate => "deflate", @@ -33,13 +33,7 @@ impl fmt::String for Encoding { Identity => "identity", EncodingExt(ref s) => s.as_slice() }) - } -} - -impl fmt::Show for Encoding { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - self.to_string().fmt(fmt) - } + } } impl str::FromStr for Encoding { diff --git a/src/header/shared/quality_item.rs b/src/header/shared/quality_item.rs index e7405e34a2..d9edecf167 100644 --- a/src/header/shared/quality_item.rs +++ b/src/header/shared/quality_item.rs @@ -9,7 +9,7 @@ use std::str; /// Represents an item with a quality value as defined in /// [RFC7231](https://tools.ietf.org/html/rfc7231#section-5.3.1). -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, Debug)] pub struct QualityItem { /// The actual contents of the field. pub item: T, @@ -26,13 +26,7 @@ impl QualityItem { } } -impl fmt::String for QualityItem { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}; q={}", self.item, format!("{:.3}", self.quality).trim_right_matches(['0', '.'].as_slice())) - } -} - -impl fmt::Show for QualityItem { +impl fmt::Display for QualityItem { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}; q={}", self.item, format!("{:.3}", self.quality).trim_right_matches(['0', '.'].as_slice())) } @@ -46,9 +40,9 @@ impl str::FromStr for QualityItem { let parts: Vec<&str> = s.rsplitn(1, ';').map(|x| x.trim()).collect(); if parts.len() == 2 { - let start = parts[0].slice(0, 2); + let start = &parts[0][0..2]; if start == "q=" || start == "Q=" { - let q_part = parts[0].slice(2, parts[0].len()); + let q_part = &parts[0][2..parts[0].len()]; if q_part.len() > 5 { return None; } diff --git a/src/http.rs b/src/http.rs index 7291f141ed..db5a241d8b 100644 --- a/src/http.rs +++ b/src/http.rs @@ -2,7 +2,6 @@ use std::borrow::Cow::{Borrowed, Owned}; use std::borrow::IntoCow; use std::cmp::min; -use std::fmt; use std::io::{self, Reader, IoResult, BufWriter}; use std::num::from_u16; use std::str::{self, FromStr}; @@ -103,7 +102,7 @@ impl Reader for HttpReader { } let to_read = min(rem as usize, buf.len()); - let count = try!(body.read(buf.slice_to_mut(to_read))) as u64; + let count = try!(body.read(&mut buf[..to_read])) as u64; rem -= count; *opt_remaining = if rem > 0 { @@ -306,23 +305,6 @@ pub const LF: u8 = b'\n'; pub const STAR: u8 = b'*'; pub const LINE_ENDING: &'static str = "\r\n"; -/// A `Show`able struct to easily write line endings to a formatter. -pub struct LineEnding; - -impl Copy for LineEnding {} - -impl fmt::String for LineEnding { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.write_str(LINE_ENDING) - } -} - -impl fmt::Show for LineEnding { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - self.to_string().fmt(fmt) - } -} - /// Determines if byte is a token char. /// /// > ```notrust diff --git a/src/lib.rs b/src/lib.rs index aa19e062e2..a21e6b919f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -145,6 +145,7 @@ pub use status::StatusCode::{Ok, BadRequest, NotFound}; pub use server::Server; use std::error::{Error, FromError}; +use std::fmt; use std::io::IoError; use self::HttpError::{HttpMethodError, HttpUriError, HttpVersionError, @@ -189,7 +190,7 @@ mod mimewrapper { pub type HttpResult = Result; /// A set of errors that can occur parsing HTTP streams. -#[derive(Show, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone)] pub enum HttpError { /// An invalid `Method`, such as `GE,T`. HttpMethodError, @@ -205,6 +206,12 @@ pub enum HttpError { HttpIoError(IoError), } +impl fmt::Display for HttpError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(self.description()) + } +} + impl Error for HttpError { fn description(&self) -> &str { match *self { diff --git a/src/method.rs b/src/method.rs index 8f75f8bc4a..323482f1f0 100644 --- a/src/method.rs +++ b/src/method.rs @@ -13,7 +13,7 @@ use self::Method::{Options, Get, Post, Put, Delete, Head, Trace, Connect, Patch, /// /// It may make sense to grow this to include all variants currently /// registered with IANA, if they are at all common to use. -#[derive(Clone, PartialEq, Eq, Hash, Show)] +#[derive(Clone, PartialEq, Eq, Hash, Debug)] pub enum Method { /// OPTIONS Options, @@ -88,9 +88,9 @@ impl FromStr for Method { } } -impl fmt::String for Method { +impl fmt::Display for Method { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - match *self { + fmt.write_str(match *self { Options => "OPTIONS", Get => "GET", Post => "POST", @@ -101,7 +101,7 @@ impl fmt::String for Method { Connect => "CONNECT", Patch => "PATCH", Extension(ref s) => s.as_slice() - }.fmt(fmt) + }) } } diff --git a/src/mock.rs b/src/mock.rs index 419895f35d..14778b88f2 100644 --- a/src/mock.rs +++ b/src/mock.rs @@ -25,7 +25,7 @@ impl PartialEq for MockStream { } } -impl fmt::Show for MockStream { +impl fmt::Debug for MockStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "MockStream {{ read: {:?}, write: {:?} }}", self.read.get_ref(), self.write.get_ref()) diff --git a/src/net.rs b/src/net.rs index 61f227c116..51e072311d 100644 --- a/src/net.rs +++ b/src/net.rs @@ -94,7 +94,7 @@ pub trait NetworkConnector { fn connect(&mut self, host: &str, port: Port, scheme: &str) -> IoResult; } -impl fmt::Show for Box { +impl fmt::Debug for Box { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt.pad("Box") } diff --git a/src/status.rs b/src/status.rs index ed93d0d287..0d6c6fbcd0 100644 --- a/src/status.rs +++ b/src/status.rs @@ -26,7 +26,7 @@ use std::cmp::Ordering::{self, Less, Equal, Greater}; /// # use hyper::status::StatusCode::{Code123, Continue}; /// assert_eq!(Code123.class().default_code(), Continue); /// ``` -#[derive(Show)] +#[derive(Debug)] pub enum StatusCode { /// 100 Continue Continue = 100, @@ -1589,7 +1589,7 @@ impl Copy for StatusCode {} /// ``` /// /// If you wish to just include the number, cast to a u16 instead. -impl fmt::String for StatusCode { +impl fmt::Display for StatusCode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{} {}", *self as u16, self.canonical_reason().unwrap_or("")) diff --git a/src/uri.rs b/src/uri.rs index 7b0f80a9cc..03589a2077 100644 --- a/src/uri.rs +++ b/src/uri.rs @@ -16,7 +16,7 @@ use url::Url; /// > / authority-form /// > / asterisk-form /// > ``` -#[derive(Show, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone)] pub enum RequestUri { /// The most common request target, an absolute path and optional query. /// diff --git a/src/version.rs b/src/version.rs index eb63fb5b2b..468c9c0ac9 100644 --- a/src/version.rs +++ b/src/version.rs @@ -7,7 +7,7 @@ use std::fmt; use self::HttpVersion::{Http09, Http10, Http11, Http20}; /// Represents a version of the HTTP spec. -#[derive(PartialEq, PartialOrd, Copy, Show)] +#[derive(PartialEq, PartialOrd, Copy, Debug)] pub enum HttpVersion { /// `HTTP/0.9` Http09, @@ -19,14 +19,14 @@ pub enum HttpVersion { Http20 } -impl fmt::String for HttpVersion { +impl fmt::Display for HttpVersion { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - match *self { + fmt.write_str(match *self { Http09 => "HTTP/0.9", Http10 => "HTTP/1.0", Http11 => "HTTP/1.1", Http20 => "HTTP/2.0", - }.fmt(fmt) + }) } }