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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user