More Rust updates:
- Some stray deriving -> derive changes
- use::{mod} -> use::{self}
- fmt.write -> fmt.write_str
This does not catch the last case of fmt.write_str in the
Show impl of a Header Item. This will need to be changed
separately.
			
			
This commit is contained in:
		| @@ -6,7 +6,7 @@ use url::Url; | ||||
| use method; | ||||
| use method::Method::{Get, Post, Delete, Put, Patch, Head, Options}; | ||||
| use header::Headers; | ||||
| use header::common::{mod, Host}; | ||||
| use header::common::{self, Host}; | ||||
| use net::{NetworkStream, NetworkConnector, HttpConnector, Fresh, Streaming}; | ||||
| use http::{HttpWriter, LINE_ENDING}; | ||||
| use http::HttpWriter::{ThroughWriter, ChunkedWriter, SizedWriter, EmptyWriter}; | ||||
|   | ||||
| @@ -7,7 +7,7 @@ use header::shared; | ||||
| /// | ||||
| /// The `Accept-Encoding` header can be used by clients to indicate what | ||||
| /// response encodings they accept. | ||||
| #[deriving(Clone, PartialEq, Show)] | ||||
| #[derive(Clone, PartialEq, Show)] | ||||
| pub struct AcceptEncoding(pub Vec<shared::QualityItem<shared::Encoding>>); | ||||
|  | ||||
| deref!(AcceptEncoding -> Vec<shared::QualityItem<shared::Encoding>>); | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| use header::{Header, HeaderFormat}; | ||||
| use method::Method; | ||||
| use std::fmt::{mod}; | ||||
| use std::fmt::{self}; | ||||
| use header::shared::util::{from_comma_delimited, fmt_comma_delimited}; | ||||
|  | ||||
| /// The `Allow` header. | ||||
| @@ -31,7 +31,7 @@ impl HeaderFormat for Allow { | ||||
| mod tests { | ||||
|     use super::Allow; | ||||
|     use header::Header; | ||||
|     use method::Method::{mod, Options, Get, Put, Post, Delete, Head, Trace, Connect, Patch, Extension}; | ||||
|     use method::Method::{self, Options, Get, Put, Post, Delete, Head, Trace, Connect, Patch, Extension}; | ||||
|  | ||||
|     #[test] | ||||
|     fn test_allow() { | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use std::str::{FromStr, from_utf8}; | ||||
| use std::ops::{Deref, DerefMut}; | ||||
| use serialize::base64::{ToBase64, FromBase64, Standard, Config, Newline}; | ||||
| use header::{Header, HeaderFormat}; | ||||
|  | ||||
| @@ -7,13 +8,15 @@ use header::{Header, HeaderFormat}; | ||||
| #[derive(Clone, PartialEq, Show)] | ||||
| pub struct Authorization<S: Scheme>(pub S); | ||||
|  | ||||
| impl<S: Scheme> Deref<S> for Authorization<S> { | ||||
| impl<S: Scheme> Deref for Authorization<S> { | ||||
|     type Target = S; | ||||
|  | ||||
|     fn deref<'a>(&'a self) -> &'a S { | ||||
|         &self.0 | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<S: Scheme> DerefMut<S> for Authorization<S> { | ||||
| impl<S: Scheme> DerefMut for Authorization<S> { | ||||
|     fn deref_mut<'a>(&'a mut self) -> &'a mut S { | ||||
|         &mut self.0 | ||||
|     } | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| use header::{Header, HeaderFormat}; | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use std::str::FromStr; | ||||
| use header::shared::util::{from_comma_delimited, fmt_comma_delimited}; | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
|  | ||||
| use header::{Header, HeaderFormat}; | ||||
| use header::shared::util::from_one_raw_str; | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| use header::{Header, HeaderFormat}; | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use header::shared::util::from_one_raw_str; | ||||
| use mime::Mime; | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| use header::{Header, HeaderFormat}; | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use std::str::from_utf8; | ||||
|  | ||||
| use cookie::Cookie; | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use std::str::FromStr; | ||||
| use time::Tm; | ||||
| use header::{Header, HeaderFormat}; | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| use header::{Header, HeaderFormat}; | ||||
| use std::fmt::{mod}; | ||||
| use std::fmt::{self}; | ||||
| use header::shared::util::from_one_raw_str; | ||||
|  | ||||
| /// The `Etag` header. | ||||
| @@ -81,7 +81,7 @@ impl Header for Etag { | ||||
| impl HeaderFormat for Etag { | ||||
|     fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | ||||
|         if self.weak { | ||||
|             try!(fmt.write(b"W/")); | ||||
|             try!(fmt.write_str("W/")); | ||||
|         } | ||||
|         write!(fmt, "\"{}\"", self.tag) | ||||
|     } | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use std::str::FromStr; | ||||
| use time::Tm; | ||||
| use header::{Header, HeaderFormat}; | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| use header::{Header, HeaderFormat}; | ||||
| use Port; | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use header::shared::util::from_one_raw_str; | ||||
|  | ||||
| /// The `Host` header. | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use std::str::FromStr; | ||||
| use time::Tm; | ||||
| use header::{Header, HeaderFormat}; | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use std::str::FromStr; | ||||
| use time::Tm; | ||||
| use header::{Header, HeaderFormat}; | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| use header::{Header, HeaderFormat}; | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use header::shared::util::from_one_raw_str; | ||||
|  | ||||
| /// The `Location` header. | ||||
|   | ||||
| @@ -60,13 +60,15 @@ macro_rules! bench_header( | ||||
|  | ||||
| macro_rules! deref( | ||||
|     ($from:ty -> $to:ty) => { | ||||
|         impl Deref<$to> for $from { | ||||
|         impl ::std::ops::Deref for $from { | ||||
|             type Target = $to; | ||||
|  | ||||
|             fn deref<'a>(&'a self) -> &'a $to { | ||||
|                 &self.0 | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         impl DerefMut<$to> for $from { | ||||
|         impl ::std::ops::DerefMut for $from { | ||||
|             fn deref_mut<'a>(&'a mut self) -> &'a mut $to { | ||||
|                 &mut self.0 | ||||
|             } | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| use header::{Header, HeaderFormat}; | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use header::shared::util::from_one_raw_str; | ||||
|  | ||||
| /// The `Server` header field. | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| use header::{Header, HeaderFormat}; | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use std::str::from_utf8; | ||||
|  | ||||
| use cookie::Cookie; | ||||
| @@ -52,7 +52,7 @@ impl HeaderFormat for SetCookie { | ||||
|     fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||
|         for (i, cookie) in self.0.iter().enumerate() { | ||||
|             if i != 0 { | ||||
|                 try!(f.write(b"\r\nSet-Cookie: ")); | ||||
|                 try!(f.write_str("\r\nSet-Cookie: ")); | ||||
|             } | ||||
|             try!(cookie.fmt(f)); | ||||
|         } | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| use header::{Header, HeaderFormat}; | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use std::str::FromStr; | ||||
| use header::shared::util::{from_comma_delimited, fmt_comma_delimited}; | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| use header::{Header, HeaderFormat}; | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use header::shared::util::from_one_raw_str; | ||||
|  | ||||
| /// The `User-Agent` header field. | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| use header::{Header, HeaderFormat, CaseInsensitive}; | ||||
| use std::fmt::{mod}; | ||||
| use std::fmt::{self}; | ||||
| use header::shared::util::{from_comma_delimited, fmt_comma_delimited, from_one_raw_str}; | ||||
|  | ||||
| /// The `Allow` header. | ||||
|   | ||||
| @@ -7,18 +7,20 @@ | ||||
| use std::any::Any; | ||||
| use std::ascii::AsciiExt; | ||||
| use std::borrow::Cow::{Borrowed, Owned}; | ||||
| use std::fmt::{mod, Show}; | ||||
| use std::fmt::{self, Show}; | ||||
| use std::intrinsics::TypeId; | ||||
| use std::raw::TraitObject; | ||||
| use std::str::{SendStr, FromStr}; | ||||
| use std::collections::HashMap; | ||||
| use std::collections::hash_map::{Iter, Entry}; | ||||
| use std::{hash, mem}; | ||||
| use std::iter::FromIterator; | ||||
| use std::borrow::IntoCow; | ||||
| use std::{hash, mem, raw}; | ||||
|  | ||||
| use mucell::MuCell; | ||||
| use uany::{UncheckedAnyDowncast, UncheckedAnyMutDowncast}; | ||||
| use uany::{UnsafeAnyExt}; | ||||
|  | ||||
| use http::{mod, LineEnding}; | ||||
| use http::{self, LineEnding}; | ||||
| use {HttpResult}; | ||||
|  | ||||
| pub use self::common::*; | ||||
| @@ -81,19 +83,20 @@ impl HeaderFormat { | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> UncheckedAnyDowncast<'a> for &'a HeaderFormat { | ||||
| impl UnsafeAnyExt for HeaderFormat { | ||||
|     #[inline] | ||||
|     unsafe fn downcast_ref_unchecked<T: 'static>(self) -> &'a T { | ||||
|         let to: TraitObject = mem::transmute_copy(&self); | ||||
|         mem::transmute(to.data) | ||||
|     unsafe fn downcast_ref_unchecked<T: 'static>(&self) -> &T { | ||||
|         mem::transmute(mem::transmute::<&HeaderFormat, raw::TraitObject>(self).data) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'a> UncheckedAnyMutDowncast<'a> for &'a mut HeaderFormat { | ||||
|     #[inline] | ||||
|     unsafe fn downcast_mut_unchecked<T: 'static>(self) -> &'a mut T { | ||||
|         let to: TraitObject = mem::transmute_copy(&self); | ||||
|         mem::transmute(to.data) | ||||
|     unsafe fn downcast_mut_unchecked<T: 'static>(&mut self) -> &mut T { | ||||
|         mem::transmute(mem::transmute::<&mut HeaderFormat, raw::TraitObject>(self).data) | ||||
|     } | ||||
|  | ||||
|     #[inline] | ||||
|     unsafe fn downcast_unchecked<T: 'static>(self: Box<HeaderFormat>) -> Box<T> { | ||||
|         mem::transmute(mem::transmute::<Box<HeaderFormat>, raw::TraitObject>(self).data) | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -278,7 +281,9 @@ pub struct HeadersItems<'a> { | ||||
|     inner: Iter<'a, CaseInsensitive, MuCell<Item>> | ||||
| } | ||||
|  | ||||
| impl<'a> Iterator<HeaderView<'a>> for HeadersItems<'a> { | ||||
| impl<'a> Iterator for HeadersItems<'a> { | ||||
|     type Item = HeaderView<'a>; | ||||
|  | ||||
|     fn next(&mut self) -> Option<HeaderView<'a>> { | ||||
|         match self.inner.next() { | ||||
|             Some((k, v)) => Some(HeaderView(k, v)), | ||||
| @@ -327,7 +332,7 @@ impl<'a> fmt::Show for HeaderView<'a> { | ||||
| } | ||||
|  | ||||
| impl<'a> Extend<HeaderView<'a>> for Headers { | ||||
|     fn extend<I: Iterator<HeaderView<'a>>>(&mut self, mut iter: I) { | ||||
|     fn extend<I: Iterator<Item=HeaderView<'a>>>(&mut self, mut iter: I) { | ||||
|         for header in iter { | ||||
|             self.data.insert((*header.0).clone(), (*header.1).clone()); | ||||
|         } | ||||
| @@ -335,7 +340,7 @@ impl<'a> Extend<HeaderView<'a>> for Headers { | ||||
| } | ||||
|  | ||||
| impl<'a> FromIterator<HeaderView<'a>> for Headers { | ||||
|     fn from_iter<I: Iterator<HeaderView<'a>>>(iter: I) -> Headers { | ||||
|     fn from_iter<I: Iterator<Item=HeaderView<'a>>>(iter: I) -> Headers { | ||||
|         let mut headers = Headers::new(); | ||||
|         headers.extend(iter); | ||||
|         headers | ||||
|   | ||||
| @@ -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. | ||||
| #[deriving(Clone, PartialEq)] | ||||
| #[derive(Clone, PartialEq)] | ||||
| pub enum Encoding { | ||||
|     /// The `chunked` encoding. | ||||
|     Chunked, | ||||
|   | ||||
| @@ -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). | ||||
| #[deriving(Clone, PartialEq)] | ||||
| #[derive(Clone, PartialEq)] | ||||
| pub struct QualityItem<T> { | ||||
|     /// The actual contents of the field. | ||||
|     pub item: T, | ||||
|   | ||||
| @@ -1,10 +1,11 @@ | ||||
| //! Pieces pertaining to the HTTP message protocol. | ||||
| use std::borrow::Cow::{Borrowed, Owned}; | ||||
| use std::borrow::IntoCow; | ||||
| use std::cmp::min; | ||||
| use std::fmt; | ||||
| use std::io::{mod, Reader, IoResult, BufWriter}; | ||||
| use std::io::{self, Reader, IoResult, BufWriter}; | ||||
| use std::num::from_u16; | ||||
| use std::str::{mod, SendStr, FromStr}; | ||||
| use std::str::{self, SendStr, FromStr}; | ||||
|  | ||||
| use url::Url; | ||||
| use url::ParseError as UrlError; | ||||
| @@ -693,7 +694,7 @@ fn expect(r: IoResult<u8>, expected: u8) -> HttpResult<()> { | ||||
|  | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
|     use std::io::{mod, MemReader, MemWriter}; | ||||
|     use std::io::{self, MemReader, MemWriter}; | ||||
|     use std::borrow::Cow::{Borrowed, Owned}; | ||||
|     use test::Bencher; | ||||
|     use uri::RequestUri; | ||||
|   | ||||
							
								
								
									
										35
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								src/lib.rs
									
									
									
									
									
								
							| @@ -1,4 +1,6 @@ | ||||
| #![feature(macro_rules, phase, default_type_params, slicing_syntax, globs)] | ||||
| #![feature(macro_rules, phase, default_type_params, | ||||
|            slicing_syntax, globs, associated_types, | ||||
|            old_orphan_check)] | ||||
| #![deny(missing_docs)] | ||||
| #![deny(warnings)] | ||||
| #![experimental] | ||||
| @@ -158,21 +160,22 @@ macro_rules! todo( | ||||
|     }) | ||||
| ); | ||||
|  | ||||
| #[allow(dead_code)] | ||||
| struct Trace; | ||||
|  | ||||
| impl fmt::Show for Trace { | ||||
|     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | ||||
|         let _ = backtrace::write(fmt); | ||||
|         Result::Ok(()) | ||||
|     } | ||||
| } | ||||
|  | ||||
| macro_rules! trace( | ||||
|     ($($arg:tt)*) => (if cfg!(not(ndebug)) { | ||||
|         log!(5, "{}\n{}", format_args!($($arg)*), ::Trace) | ||||
|     }) | ||||
| ); | ||||
| // FIXME(reem): Uncomment this when backtrace::write can write to a fmt::Formatter. | ||||
| // #[allow(dead_code)] | ||||
| // struct Trace; | ||||
| // | ||||
| // impl fmt::Show for Trace { | ||||
| //     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | ||||
| //         let _ = backtrace::write(fmt); | ||||
| //         Result::Ok(()) | ||||
| //     } | ||||
| // } | ||||
| // | ||||
| // macro_rules! trace( | ||||
| //     ($($arg:tt)*) => (if cfg!(not(ndebug)) { | ||||
| //         log!(5, "{}\n{}", format_args!($($arg)*), ::Trace) | ||||
| //     }) | ||||
| // ); | ||||
|  | ||||
| macro_rules! inspect( | ||||
|     ($name:expr, $value:expr) => ({ | ||||
|   | ||||
							
								
								
									
										12
									
								
								src/net.rs
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/net.rs
									
									
									
									
									
								
							| @@ -7,10 +7,10 @@ use std::io::{IoResult, IoError, ConnectionAborted, InvalidInput, OtherIoError, | ||||
|               Stream, Listener, Acceptor}; | ||||
| use std::io::net::ip::{SocketAddr, ToSocketAddr, Port}; | ||||
| use std::io::net::tcp::{TcpStream, TcpListener, TcpAcceptor}; | ||||
| use std::mem::{mod, transmute, transmute_copy}; | ||||
| use std::raw::{mod, TraitObject}; | ||||
| use std::mem::{self, transmute, transmute_copy}; | ||||
| use std::raw::{self, TraitObject}; | ||||
|  | ||||
| use uany::UncheckedBoxAnyDowncast; | ||||
| use uany::UnsafeAnyExt; | ||||
| use openssl::ssl::{Ssl, SslStream, SslContext, VerifyCallback}; | ||||
| use openssl::ssl::SslVerifyMode::SslVerifyPeer; | ||||
| use openssl::ssl::SslMethod::Sslv23; | ||||
| @@ -107,12 +107,12 @@ impl<'a> Writer for &'a mut NetworkStream { | ||||
|  | ||||
| impl UnsafeAnyExt for NetworkStream + Send { | ||||
|     unsafe fn downcast_ref_unchecked<T: 'static>(&self) -> &T { | ||||
|         mem::transmute(mem::transmute::<&NetworkStream + Send, | ||||
|         mem::transmute(mem::transmute::<&(NetworkStream + Send), | ||||
|                                         raw::TraitObject>(self).data) | ||||
|     } | ||||
|  | ||||
|     unsafe fn downcast_mut_unchecked<T: 'static>(&mut self) -> &mut T { | ||||
|         mem::transmute(mem::transmute::<&mut NetworkStream + Send, | ||||
|         mem::transmute(mem::transmute::<&mut (NetworkStream + Send), | ||||
|                                         raw::TraitObject>(self).data) | ||||
|     } | ||||
|  | ||||
| @@ -301,7 +301,7 @@ fn lift_ssl_error(ssl: SslError) -> IoError { | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
|     use std::boxed::BoxAny; | ||||
|     use uany::UncheckedBoxAnyDowncast; | ||||
|     use uany::UnsafeAnyExt; | ||||
|  | ||||
|     use mock::MockStream; | ||||
|     use super::NetworkStream; | ||||
|   | ||||
| @@ -7,7 +7,7 @@ use std::io::net::ip::SocketAddr; | ||||
|  | ||||
| use {HttpResult}; | ||||
| use version::{HttpVersion}; | ||||
| use method::Method::{mod, Get, Head}; | ||||
| use method::Method::{self, Get, Head}; | ||||
| use header::Headers; | ||||
| use header::common::{ContentLength, TransferEncoding}; | ||||
| use http::{read_request_line}; | ||||
|   | ||||
| @@ -1,7 +1,10 @@ | ||||
| //! Status Codes | ||||
| use std::fmt; | ||||
| use std::num::{FromPrimitive, ToPrimitive}; | ||||
| use std::mem::transmute; | ||||
|  | ||||
| use std::cmp::Ordering::{self, Less, Equal, Greater}; | ||||
|  | ||||
| // shamelessly lifted from Teepee. I tried a few schemes, this really | ||||
| // does seem like the best. | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user