diff --git a/src/encoding.rs b/src/encoding.rs index 0171461f..258d91fa 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -19,7 +19,7 @@ use std::borrow::Cow; #[cfg(feature = "query_encoding")] pub use self::encoding::types::EncodingRef; #[cfg(feature = "query_encoding")] -#[deriving(Copy)] +#[derive(Copy)] pub struct EncodingOverride { /// `None` means UTF-8. encoding: Option @@ -70,7 +70,7 @@ impl EncodingOverride { #[cfg(not(feature = "query_encoding"))] -#[deriving(Copy)] +#[derive(Copy)] pub struct EncodingOverride; #[cfg(not(feature = "query_encoding"))] diff --git a/src/format.rs b/src/format.rs index ac679785..116a64aa 100644 --- a/src/format.rs +++ b/src/format.rs @@ -12,7 +12,7 @@ //! //! You can use `.to_string()`, as the formatters implement `Show`. -use std::fmt::{mod, Show, Formatter}; +use std::fmt::{self, Show, Formatter}; use super::Url; /// Formatter and serializer for URL path data. @@ -24,7 +24,7 @@ pub struct PathFormatter<'a, T:'a> { impl<'a, T: Str + Show> Show for PathFormatter<'a, T> { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { if self.path.is_empty() { - formatter.write(b"/") + formatter.write_str("/") } else { for path_part in self.path.iter() { try!("/".fmt(formatter)); @@ -50,15 +50,15 @@ pub struct UserInfoFormatter<'a> { impl<'a> Show for UserInfoFormatter<'a> { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { if !self.username.is_empty() || self.password.is_some() { - try!(formatter.write(self.username.as_bytes())); + try!(formatter.write_str(self.username)); match self.password { None => (), Some(password) => { - try!(formatter.write(b":")); - try!(formatter.write(password.as_bytes())); + try!(formatter.write_str(":")); + try!(formatter.write_str(password)); } } - try!(formatter.write(b"@")); + try!(formatter.write_str("@")); } Ok(()) } @@ -72,14 +72,14 @@ pub struct UrlNoFragmentFormatter<'a> { impl<'a> Show for UrlNoFragmentFormatter<'a> { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { - try!(formatter.write(self.url.scheme.as_bytes())); - try!(formatter.write(b":")); + try!(formatter.write_str(self.url.scheme.as_slice())); + try!(formatter.write_str(":")); try!(self.url.scheme_data.fmt(formatter)); match self.url.query { None => (), Some(ref query) => { - try!(formatter.write(b"?")); - try!(formatter.write(query.as_bytes())); + try!(formatter.write_str("?")); + try!(formatter.write_str(query.as_slice())); } } Ok(()) diff --git a/src/host.rs b/src/host.rs index 04367ea0..5f793aec 100644 --- a/src/host.rs +++ b/src/host.rs @@ -8,13 +8,13 @@ use std::ascii::{AsciiExt, OwnedAsciiExt}; use std::cmp; -use std::fmt::{mod, Formatter, Show}; +use std::fmt::{self, Formatter, Show}; use parser::{ParseResult, ParseError}; use percent_encoding::{from_hex, percent_decode}; /// The host name of an URL. -#[deriving(PartialEq, Eq, Clone)] +#[derive(PartialEq, Eq, Clone)] pub enum Host { /// A (DNS) domain name or an IPv4 address. /// @@ -30,7 +30,7 @@ pub enum Host { /// A 128 bit IPv6 address -#[deriving(Clone, Eq, PartialEq, Copy)] +#[derive(Clone, Eq, PartialEq, Copy)] pub struct Ipv6Address { pub pieces: [u16; 8] } @@ -82,9 +82,9 @@ impl Show for Host { match *self { Host::Domain(ref domain) => domain.fmt(formatter), Host::Ipv6(ref address) => { - try!(formatter.write(b"[")); + try!(formatter.write_str("[")); try!(address.fmt(formatter)); - formatter.write(b"]") + formatter.write_str("]") } } } @@ -224,9 +224,9 @@ impl Show for Ipv6Address { let mut i = 0; while i < 8 { if i == compress_start { - try!(formatter.write(b":")); + try!(formatter.write_str(":")); if i == 0 { - try!(formatter.write(b":")); + try!(formatter.write_str(":")); } if compress_end < 8 { i = compress_end; @@ -236,7 +236,7 @@ impl Show for Ipv6Address { } try!(write!(formatter, "{:x}", self.pieces[i as uint])); if i < 7 { - try!(formatter.write(b":")); + try!(formatter.write_str(":")); } i += 1; } diff --git a/src/lib.rs b/src/lib.rs index 10d9015e..0f61d248 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,11 +119,11 @@ assert!(css_url.serialize() == "http://servo.github.io/rust-url/main.css".to_str */ -#![feature(macro_rules, default_type_params)] +#![feature(macro_rules, default_type_params, old_orphan_check)] extern crate "rustc-serialize" as rustc_serialize; -use std::fmt::{mod, Formatter, Show}; +use std::fmt::{self, Formatter, Show}; use std::hash; use std::path; @@ -155,7 +155,7 @@ mod tests; /// The parsed representation of an absolute URL. -#[deriving(PartialEq, Eq, Clone)] +#[derive(PartialEq, Eq, Clone)] pub struct Url { /// The scheme (a.k.a. protocol) of the URL, in ASCII lower case. pub scheme: String, @@ -186,7 +186,7 @@ pub struct Url { } /// The components of the URL whose representation depends on where the scheme is *relative*. -#[deriving(PartialEq, Eq, Clone)] +#[derive(PartialEq, Eq, Clone)] pub enum SchemeData { /// Components for URLs in a *relative* scheme such as HTTP. Relative(RelativeSchemeData), @@ -200,7 +200,7 @@ pub enum SchemeData { } /// Components for URLs in a *relative* scheme such as HTTP. -#[deriving(PartialEq, Eq, Clone)] +#[derive(PartialEq, Eq, Clone)] pub struct RelativeSchemeData { /// The username of the URL, as a possibly empty, pecent-encoded string. /// @@ -403,7 +403,7 @@ impl<'a> UrlParser<'a> { /// Determines the behavior of the URL parser for a given scheme. -#[deriving(PartialEq, Eq, Copy)] +#[derive(PartialEq, Eq, Copy)] pub enum SchemeType { /// Indicate that the scheme is *non-relative*. /// @@ -772,8 +772,8 @@ impl Show for Url { match self.fragment { None => (), Some(ref fragment) => { - try!(formatter.write(b"#")); - try!(formatter.write(fragment.as_bytes())); + try!(formatter.write_str("#")); + try!(formatter.write_str(fragment.as_slice())); } } Ok(()) @@ -889,7 +889,7 @@ impl RelativeSchemeData { impl Show for RelativeSchemeData { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { // Write the scheme-trailing double slashes. - try!(formatter.write(b"//")); + try!(formatter.write_str("//")); // Write the user info. try!(UserInfoFormatter { diff --git a/src/parser.rs b/src/parser.rs index 722f5e0b..29b8f2d2 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -8,7 +8,7 @@ use std::ascii::AsciiExt; use std::error::Error; -use std::fmt::{mod, Formatter, Show}; +use std::fmt::{self, Formatter, Show}; use std::str::CharRange; use super::{UrlParser, Url, SchemeData, RelativeSchemeData, Host, SchemeType}; @@ -31,7 +31,7 @@ pub type ParseResult = Result; macro_rules! simple_enum_error { ($($name: ident => $description: expr,)+) => { /// Errors that can occur during parsing. - #[deriving(PartialEq, Eq, Clone, Copy)] + #[derive(PartialEq, Eq, Clone, Copy)] pub enum ParseError { $( $name, @@ -92,7 +92,7 @@ impl Show for ParseError { pub type ErrorHandler = fn(reason: ParseError) -> ParseResult<()>; -#[deriving(PartialEq, Eq)] +#[derive(PartialEq, Eq)] pub enum Context { UrlParser, Setter, diff --git a/src/percent_encoding.rs b/src/percent_encoding.rs index 9d45cbc6..44ebc292 100644 --- a/src/percent_encoding.rs +++ b/src/percent_encoding.rs @@ -27,7 +27,7 @@ mod encode_sets; /// If you need a different encode set, /// please [file a bug](https://github.com/servo/rust-url/issues) /// explaining the use case. -#[deriving(Copy)] +#[derive(Copy)] pub struct EncodeSet { map: &'static [&'static str; 256], }