#[deriving] -> #[derive]

This commit is contained in:
Jonathan Reem
2015-01-03 13:15:54 +01:00
parent 541e21dbd1
commit 7f3a33f903
32 changed files with 43 additions and 43 deletions

View File

@@ -46,7 +46,7 @@ fn bench_curl(b: &mut test::Bencher) {
listening.close().unwrap(); listening.close().unwrap();
} }
#[deriving(Clone)] #[derive(Clone)]
struct Foo; struct Foo;
impl hyper::header::Header for Foo { impl hyper::header::Header for Foo {

View File

@@ -65,7 +65,7 @@ fn bench_mock_curl(b: &mut test::Bencher) {
}); });
} }
#[deriving(Clone)] #[derive(Clone)]
struct Foo; struct Foo;
impl hyper::header::Header for Foo { impl hyper::header::Header for Foo {

View File

@@ -315,7 +315,7 @@ impl<'a> IntoUrl for &'a str {
} }
/// Behavior regarding how to handle redirects within a Client. /// Behavior regarding how to handle redirects within a Client.
#[deriving(Copy)] #[derive(Copy)]
pub enum RedirectPolicy { pub enum RedirectPolicy {
/// Don't follow any redirects. /// Don't follow any redirects.
FollowNone, FollowNone,

View File

@@ -25,7 +25,7 @@ use mime;
/// qitem(Mime(Text, Html, vec![])), /// qitem(Mime(Text, Html, vec![])),
/// qitem(Mime(Text, Xml, vec![])) ])); /// qitem(Mime(Text, Xml, vec![])) ]));
/// ``` /// ```
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct Accept(pub Vec<shared::QualityItem<mime::Mime>>); pub struct Accept(pub Vec<shared::QualityItem<mime::Mime>>);
deref!(Accept -> Vec<shared::QualityItem<mime::Mime>>); deref!(Accept -> Vec<shared::QualityItem<mime::Mime>>);

View File

@@ -6,7 +6,7 @@ use header::shared::util::{from_comma_delimited, fmt_comma_delimited};
/// The `Allow` header. /// The `Allow` header.
/// See also https://tools.ietf.org/html/rfc7231#section-7.4.1 /// See also https://tools.ietf.org/html/rfc7231#section-7.4.1
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct Allow(pub Vec<Method>); pub struct Allow(pub Vec<Method>);
deref!(Allow -> Vec<Method>); deref!(Allow -> Vec<Method>);

View File

@@ -4,7 +4,7 @@ use serialize::base64::{ToBase64, FromBase64, Standard, Config, Newline};
use header::{Header, HeaderFormat}; use header::{Header, HeaderFormat};
/// The `Authorization` header field. /// The `Authorization` header field.
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct Authorization<S: Scheme>(pub S); pub struct Authorization<S: Scheme>(pub S);
impl<S: Scheme> Deref<S> for Authorization<S> { impl<S: Scheme> Deref<S> for Authorization<S> {
@@ -72,7 +72,7 @@ impl Scheme for String {
} }
/// Credential holder for Basic Authentication /// Credential holder for Basic Authentication
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct Basic { pub struct Basic {
/// The username as a possibly empty string /// The username as a possibly empty string
pub username: String, pub username: String,

View File

@@ -4,7 +4,7 @@ use header::{Header, HeaderFormat};
use header::shared::util::{from_one_comma_delimited, fmt_comma_delimited}; use header::shared::util::{from_one_comma_delimited, fmt_comma_delimited};
/// The Cache-Control header. /// The Cache-Control header.
#[deriving(PartialEq, Clone, Show)] #[derive(PartialEq, Clone, Show)]
pub struct CacheControl(pub Vec<CacheDirective>); pub struct CacheControl(pub Vec<CacheDirective>);
deref!(CacheControl -> Vec<CacheDirective>); deref!(CacheControl -> Vec<CacheDirective>);
@@ -34,7 +34,7 @@ impl HeaderFormat for CacheControl {
} }
/// CacheControl contains a list of these directives. /// CacheControl contains a list of these directives.
#[deriving(PartialEq, Clone)] #[derive(PartialEq, Clone)]
pub enum CacheDirective { pub enum CacheDirective {
/// "no-cache" /// "no-cache"
NoCache, NoCache,

View File

@@ -6,13 +6,13 @@ use header::shared::util::{from_comma_delimited, fmt_comma_delimited};
pub use self::ConnectionOption::{KeepAlive, Close, ConnectionHeader}; pub use self::ConnectionOption::{KeepAlive, Close, ConnectionHeader};
/// The `Connection` header. /// The `Connection` header.
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct Connection(pub Vec<ConnectionOption>); pub struct Connection(pub Vec<ConnectionOption>);
deref!(Connection -> Vec<ConnectionOption>); deref!(Connection -> Vec<ConnectionOption>);
/// Values that can be in the `Connection` header. /// Values that can be in the `Connection` header.
#[deriving(Clone, PartialEq)] #[derive(Clone, PartialEq)]
pub enum ConnectionOption { pub enum ConnectionOption {
/// The `keep-alive` connection value. /// The `keep-alive` connection value.
KeepAlive, KeepAlive,

View File

@@ -6,7 +6,7 @@ use header::shared::util::from_one_raw_str;
/// The `Content-Length` header. /// The `Content-Length` header.
/// ///
/// Simply a wrapper around a `uint`. /// Simply a wrapper around a `uint`.
#[deriving(Copy, Clone, PartialEq, Show)] #[derive(Copy, Clone, PartialEq, Show)]
pub struct ContentLength(pub uint); pub struct ContentLength(pub uint);
deref!(ContentLength -> uint); deref!(ContentLength -> uint);

View File

@@ -7,7 +7,7 @@ use mime::Mime;
/// ///
/// Used to describe the MIME type of message body. Can be used with both /// Used to describe the MIME type of message body. Can be used with both
/// requests and responses. /// requests and responses.
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct ContentType(pub Mime); pub struct ContentType(pub Mime);
deref!(ContentType -> Mime); deref!(ContentType -> Mime);

View File

@@ -13,7 +13,7 @@ use cookie::CookieJar;
/// ///
/// > When the user agent generates an HTTP request, the user agent MUST NOT /// > When the user agent generates an HTTP request, the user agent MUST NOT
/// > attach more than one Cookie header field. /// > attach more than one Cookie header field.
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct Cookies(pub Vec<Cookie>); pub struct Cookies(pub Vec<Cookie>);
//TODO: remove when fixed in libstd //TODO: remove when fixed in libstd

View File

@@ -7,7 +7,7 @@ use header::shared::time::tm_from_str;
// Egh, replace as soon as something better than time::Tm exists. // Egh, replace as soon as something better than time::Tm exists.
/// The `Date` header field. /// The `Date` header field.
#[deriving(Copy, PartialEq, Clone)] #[derive(Copy, PartialEq, Clone)]
pub struct Date(pub Tm); pub struct Date(pub Tm);
deref!(Date -> Tm); deref!(Date -> Tm);

View File

@@ -8,7 +8,7 @@ use header::shared::util::from_one_raw_str;
/// Preceding the first double quote is an optional weakness indicator, /// Preceding the first double quote is an optional weakness indicator,
/// which always looks like this: W/ /// which always looks like this: W/
/// See also: https://tools.ietf.org/html/rfc7232#section-2.3 /// See also: https://tools.ietf.org/html/rfc7232#section-2.3
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct Etag { pub struct Etag {
/// Weakness indicator for the tag /// Weakness indicator for the tag
pub weak: bool, pub weak: bool,

View File

@@ -6,7 +6,7 @@ use header::shared::util::from_one_raw_str;
use header::shared::time::tm_from_str; use header::shared::time::tm_from_str;
/// The `Expires` header field. /// The `Expires` header field.
#[deriving(Copy, PartialEq, Clone)] #[derive(Copy, PartialEq, Clone)]
pub struct Expires(pub Tm); pub struct Expires(pub Tm);
deref!(Expires -> Tm); deref!(Expires -> Tm);

View File

@@ -10,7 +10,7 @@ use header::shared::util::from_one_raw_str;
/// ///
/// Currently is just a String, but it should probably become a better type, /// Currently is just a String, but it should probably become a better type,
/// like url::Host or something. /// like url::Host or something.
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct Host { pub struct Host {
/// The hostname, such a example.domain. /// The hostname, such a example.domain.
pub hostname: String, pub hostname: String,

View File

@@ -6,7 +6,7 @@ use header::shared::util::from_one_raw_str;
use header::shared::time::tm_from_str; use header::shared::time::tm_from_str;
/// The `If-Modified-Since` header field. /// The `If-Modified-Since` header field.
#[deriving(Copy, PartialEq, Clone)] #[derive(Copy, PartialEq, Clone)]
pub struct IfModifiedSince(pub Tm); pub struct IfModifiedSince(pub Tm);
deref!(IfModifiedSince -> Tm); deref!(IfModifiedSince -> Tm);

View File

@@ -6,7 +6,7 @@ use header::shared::util::from_one_raw_str;
use header::shared::time::tm_from_str; use header::shared::time::tm_from_str;
/// The `LastModified` header field. /// The `LastModified` header field.
#[deriving(Copy, PartialEq, Clone)] #[derive(Copy, PartialEq, Clone)]
pub struct LastModified(pub Tm); pub struct LastModified(pub Tm);
deref!(LastModified -> Tm); deref!(LastModified -> Tm);

View File

@@ -13,7 +13,7 @@ use header::shared::util::from_one_raw_str;
/// ///
/// Currently is just a String, but it should probably become a better type, /// Currently is just a String, but it should probably become a better type,
/// like url::Url or something. /// like url::Url or something.
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct Location(pub String); pub struct Location(pub String);
deref!(Location -> String); deref!(Location -> String);

View File

@@ -5,7 +5,7 @@ use header::shared::util::from_one_raw_str;
/// The `Server` header field. /// The `Server` header field.
/// ///
/// They can contain any value, so it just wraps a `String`. /// They can contain any value, so it just wraps a `String`.
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct Server(pub String); pub struct Server(pub String);
deref!(Server -> String); deref!(Server -> String);

View File

@@ -10,7 +10,7 @@ use cookie::CookieJar;
/// Informally, the Set-Cookie response header contains the header name /// Informally, the Set-Cookie response header contains the header name
/// "Set-Cookie" followed by a ":" and a cookie. Each cookie begins with /// "Set-Cookie" followed by a ":" and a cookie. Each cookie begins with
/// a name-value-pair, followed by zero or more attribute-value pairs. /// a name-value-pair, followed by zero or more attribute-value pairs.
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct SetCookie(pub Vec<Cookie>); pub struct SetCookie(pub Vec<Cookie>);
//TODO: remove when fixed in libstd //TODO: remove when fixed in libstd

View File

@@ -18,7 +18,7 @@ use self::Encoding::{Chunked, Gzip, Deflate, Compress, EncodingExt};
/// this header should include `chunked` as the last encoding. /// this header should include `chunked` as the last encoding.
/// ///
/// The implementation uses a vector of `Encoding` values. /// The implementation uses a vector of `Encoding` values.
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct TransferEncoding(pub Vec<Encoding>); pub struct TransferEncoding(pub Vec<Encoding>);
deref!(TransferEncoding -> Vec<Encoding>); deref!(TransferEncoding -> Vec<Encoding>);
@@ -33,7 +33,7 @@ deref!(TransferEncoding -> Vec<Encoding>);
/// # use hyper::header::Headers; /// # use hyper::header::Headers;
/// # let mut headers = Headers::new(); /// # let mut headers = Headers::new();
/// headers.set(TransferEncoding(vec![Gzip, Chunked])); /// headers.set(TransferEncoding(vec![Gzip, Chunked]));
#[deriving(Clone, PartialEq)] #[derive(Clone, PartialEq)]
pub enum Encoding { pub enum Encoding {
/// The `chunked` encoding. /// The `chunked` encoding.
Chunked, Chunked,

View File

@@ -6,13 +6,13 @@ use header::shared::util::{from_comma_delimited, fmt_comma_delimited};
use self::Protocol::{WebSocket, ProtocolExt}; use self::Protocol::{WebSocket, ProtocolExt};
/// The `Upgrade` header. /// The `Upgrade` header.
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct Upgrade(pub Vec<Protocol>); pub struct Upgrade(pub Vec<Protocol>);
deref!(Upgrade -> Vec<Protocol>); deref!(Upgrade -> Vec<Protocol>);
/// Protocol values that can appear in the Upgrade header. /// Protocol values that can appear in the Upgrade header.
#[deriving(Clone, PartialEq)] #[derive(Clone, PartialEq)]
pub enum Protocol { pub enum Protocol {
/// The websocket protocol. /// The websocket protocol.
WebSocket, WebSocket,

View File

@@ -5,7 +5,7 @@ use header::shared::util::from_one_raw_str;
/// The `User-Agent` header field. /// The `User-Agent` header field.
/// ///
/// They can contain any value, so it just wraps a `String`. /// They can contain any value, so it just wraps a `String`.
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub struct UserAgent(pub String); pub struct UserAgent(pub String);
deref!(UserAgent -> String); deref!(UserAgent -> String);

View File

@@ -5,7 +5,7 @@ use header::shared::util::{from_comma_delimited, fmt_comma_delimited, from_one_r
/// The `Allow` header. /// The `Allow` header.
/// See also https://tools.ietf.org/html/rfc7231#section-7.1.4 /// See also https://tools.ietf.org/html/rfc7231#section-7.1.4
#[deriving(Clone, PartialEq, Show)] #[derive(Clone, PartialEq, Show)]
pub enum Vary { pub enum Vary {
/// This corresponds to '*'. /// This corresponds to '*'.
Any, Any,

View File

@@ -110,7 +110,7 @@ fn header_name<T: Header>() -> &'static str {
} }
/// A map of header fields on requests and responses. /// A map of header fields on requests and responses.
#[deriving(Clone)] #[derive(Clone)]
pub struct Headers { pub struct Headers {
data: HashMap<CaseInsensitive, MuCell<Item>> data: HashMap<CaseInsensitive, MuCell<Item>>
} }
@@ -342,7 +342,7 @@ impl<'a> FromIterator<HeaderView<'a>> for Headers {
} }
} }
#[deriving(Clone)] #[derive(Clone)]
struct Item { struct Item {
raw: Option<Vec<Vec<u8>>>, raw: Option<Vec<Vec<u8>>>,
typed: Option<Box<HeaderFormat + Send + Sync>> typed: Option<Box<HeaderFormat + Send + Sync>>
@@ -450,7 +450,7 @@ impl fmt::Show for Box<HeaderFormat + Send + Sync> {
} }
/// Case-insensitive string. /// Case-insensitive string.
//#[deriving(Clone)] //#[derive(Clone)]
pub struct CaseInsensitive(SendStr); pub struct CaseInsensitive(SendStr);
impl FromStr for CaseInsensitive { impl FromStr for CaseInsensitive {
@@ -562,7 +562,7 @@ mod tests {
assert_eq!(accept, Some(Accept(vec![application_vendor, text_plain]))); assert_eq!(accept, Some(Accept(vec![application_vendor, text_plain])));
} }
#[deriving(Clone, Show)] #[derive(Clone, Show)]
struct CrazyLength(Option<bool>, uint); struct CrazyLength(Option<bool>, uint);
impl Header for CrazyLength { impl Header for CrazyLength {

View File

@@ -582,7 +582,7 @@ pub fn read_request_line<R: Reader>(stream: &mut R) -> HttpResult<RequestLine> {
pub type StatusLine = (HttpVersion, RawStatus); pub type StatusLine = (HttpVersion, RawStatus);
/// The raw status code and reason-phrase. /// The raw status code and reason-phrase.
#[deriving(PartialEq, Show)] #[derive(PartialEq, Show)]
pub struct RawStatus(pub u16, pub SendStr); pub struct RawStatus(pub u16, pub SendStr);
impl Clone for RawStatus { impl Clone for RawStatus {

View File

@@ -207,7 +207,7 @@ mod mimewrapper {
pub type HttpResult<T> = Result<T, HttpError>; pub type HttpResult<T> = Result<T, HttpError>;
/// A set of errors that can occur parsing HTTP streams. /// A set of errors that can occur parsing HTTP streams.
#[deriving(Show, PartialEq, Clone)] #[derive(Show, PartialEq, Clone)]
pub enum HttpError { pub enum HttpError {
/// An invalid `Method`, such as `GE,T`. /// An invalid `Method`, such as `GE,T`.
HttpMethodError, HttpMethodError,

View File

@@ -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 /// It may make sense to grow this to include all variants currently
/// registered with IANA, if they are at all common to use. /// registered with IANA, if they are at all common to use.
#[deriving(Clone, PartialEq, Eq, Hash)] #[derive(Clone, PartialEq, Eq, Hash)]
pub enum Method { pub enum Method {
/// OPTIONS /// OPTIONS
Options, Options,

View File

@@ -182,7 +182,7 @@ impl NetworkListener<HttpStream, HttpAcceptor> for HttpListener {
} }
/// A `NetworkAcceptor` for `HttpStream`s. /// A `NetworkAcceptor` for `HttpStream`s.
#[deriving(Clone)] #[derive(Clone)]
pub struct HttpAcceptor { pub struct HttpAcceptor {
inner: TcpAcceptor inner: TcpAcceptor
} }
@@ -202,7 +202,7 @@ impl NetworkAcceptor<HttpStream> for HttpAcceptor {
} }
/// A wrapper around a TcpStream. /// A wrapper around a TcpStream.
#[deriving(Clone)] #[derive(Clone)]
pub enum HttpStream { pub enum HttpStream {
/// A stream over the HTTP protocol. /// A stream over the HTTP protocol.
Http(TcpStream), Http(TcpStream),

View File

@@ -1038,7 +1038,7 @@ impl StatusCode {
/// other times. /// other times.
/// ///
/// The reason phrase is defined as being exclusively for human readers. You should avoid /// The reason phrase is defined as being exclusively for human readers. You should avoid
/// deriving any meaning from it at all costs. /// derive any meaning from it at all costs.
/// ///
/// Bear in mind also that in HTTP/2.0 the reason phrase is abolished from transmission, and so /// Bear in mind also that in HTTP/2.0 the reason phrase is abolished from transmission, and so
/// this canonical reason phrase really is the only reason phrase youll find. /// this canonical reason phrase really is the only reason phrase youll find.
@@ -1600,7 +1600,7 @@ impl PartialEq for StatusCode {
impl Eq for StatusCode {} impl Eq for StatusCode {}
// Ditto (though #[deriving(Clone)] only takes about 0.4 seconds). // Ditto (though #[derive(Clone)] only takes about 0.4 seconds).
impl Clone for StatusCode { impl Clone for StatusCode {
#[inline] #[inline]
fn clone(&self) -> StatusCode { fn clone(&self) -> StatusCode {
@@ -1686,7 +1686,7 @@ impl ToPrimitive for StatusCode {
/// to get the appropriate *category* of status. /// to get the appropriate *category* of status.
/// ///
/// For HTTP/2.0, the 1xx Informational class is invalid. /// For HTTP/2.0, the 1xx Informational class is invalid.
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord, Copy)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Copy)]
pub enum StatusClass { pub enum StatusClass {
/// 1xx: Informational - Request received, continuing process /// 1xx: Informational - Request received, continuing process
Informational = 100, Informational = 100,

View File

@@ -16,7 +16,7 @@ use url::Url;
/// > / authority-form /// > / authority-form
/// > / asterisk-form /// > / asterisk-form
/// > ``` /// > ```
#[deriving(Show, PartialEq, Clone)] #[derive(Show, PartialEq, Clone)]
pub enum RequestUri { pub enum RequestUri {
/// The most common request target, an absolute path and optional query. /// The most common request target, an absolute path and optional query.
/// ///

View File

@@ -7,7 +7,7 @@ use std::fmt;
use self::HttpVersion::{Http09, Http10, Http11, Http20}; use self::HttpVersion::{Http09, Http10, Http11, Http20};
/// Represents a version of the HTTP spec. /// Represents a version of the HTTP spec.
#[deriving(PartialEq, PartialOrd, Copy)] #[derive(PartialEq, PartialOrd, Copy)]
pub enum HttpVersion { pub enum HttpVersion {
/// `HTTP/0.9` /// `HTTP/0.9`
Http09, Http09,