Skip to content

update rust & fix tests #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/form_urlencoded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn parse_internal(input: &[u8], mut encoding_override: EncodingOverride, mut use
for piece in input.split(|&b| b == b'&') {
if !piece.is_empty() {
let (name, value) = match piece.position_elem(&b'=') {
Some(position) => (piece.slice_to(position), piece.slice_from(position + 1)),
Some(position) => (&piece[..position], &piece[position + 1..]),
None => (piece, [].as_slice())
};

Expand Down
8 changes: 4 additions & 4 deletions src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//!
//! These formatters can be used to coerce various URL parts into strings.
//!
//! You can use `<formatter>.to_string()`, as the formatters implement `fmt::String`.
//! You can use `<formatter>.to_string()`, as the formatters implement `fmt::Display`.

use std::fmt::{self, Formatter};
use super::Url;
Expand All @@ -21,7 +21,7 @@ pub struct PathFormatter<'a, T:'a> {
pub path: &'a [T]
}

impl<'a, T: Str + fmt::String> fmt::String for PathFormatter<'a, T> {
impl<'a, T: Str + fmt::Display> fmt::Display for PathFormatter<'a, T> {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
if self.path.is_empty() {
formatter.write_str("/")
Expand All @@ -47,7 +47,7 @@ pub struct UserInfoFormatter<'a> {
pub password: Option<&'a str>
}

impl<'a> fmt::String for UserInfoFormatter<'a> {
impl<'a> fmt::Display for UserInfoFormatter<'a> {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
if !self.username.is_empty() || self.password.is_some() {
try!(formatter.write_str(self.username));
Expand All @@ -67,7 +67,7 @@ pub struct UrlNoFragmentFormatter<'a> {
pub url: &'a Url
}

impl<'a> fmt::String for UrlNoFragmentFormatter<'a> {
impl<'a> fmt::Display for UrlNoFragmentFormatter<'a> {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
try!(formatter.write_str(self.url.scheme.as_slice()));
try!(formatter.write_str(":"));
Expand Down
10 changes: 5 additions & 5 deletions src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use percent_encoding::{from_hex, percent_decode};


/// The host name of an URL.
#[derive(PartialEq, Eq, Clone, Show)]
#[derive(PartialEq, Eq, Clone, Debug)]
pub enum Host {
/// A (DNS) domain name or an IPv4 address.
///
Expand All @@ -30,7 +30,7 @@ pub enum Host {


/// A 128 bit IPv6 address
#[derive(Clone, Eq, PartialEq, Copy, Show)]
#[derive(Clone, Eq, PartialEq, Copy, Debug)]
pub struct Ipv6Address {
pub pieces: [u16; 8]
}
Expand All @@ -48,7 +48,7 @@ impl Host {
Err(ParseError::EmptyHost)
} else if input.starts_with("[") {
if input.ends_with("]") {
Ipv6Address::parse(input.slice(1, input.len() - 1)).map(Host::Ipv6)
Ipv6Address::parse(&input[1..input.len() - 1]).map(Host::Ipv6)
} else {
Err(ParseError::InvalidIpv6Address)
}
Expand Down Expand Up @@ -77,7 +77,7 @@ impl Host {
}


impl fmt::String for Host {
impl fmt::Display for Host {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
match *self {
Host::Domain(ref domain) => domain.fmt(formatter),
Expand Down Expand Up @@ -218,7 +218,7 @@ impl Ipv6Address {
}


impl fmt::String for Ipv6Address {
impl fmt::Display for Ipv6Address {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
let (compress_start, compress_end) = longest_zero_sequence(&self.pieces);
let mut i = 0;
Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ mod tests;


/// The parsed representation of an absolute URL.
#[derive(PartialEq, Eq, Clone, Show)]
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct Url {
/// The scheme (a.k.a. protocol) of the URL, in ASCII lower case.
pub scheme: String,
Expand Down Expand Up @@ -188,7 +188,7 @@ pub struct Url {
}

/// The components of the URL whose representation depends on where the scheme is *relative*.
#[derive(PartialEq, Eq, Clone, Show)]
#[derive(PartialEq, Eq, Clone, Debug)]
pub enum SchemeData {
/// Components for URLs in a *relative* scheme such as HTTP.
Relative(RelativeSchemeData),
Expand All @@ -202,7 +202,7 @@ pub enum SchemeData {
}

/// Components for URLs in a *relative* scheme such as HTTP.
#[derive(PartialEq, Eq, Clone, Show)]
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct RelativeSchemeData {
/// The username of the URL, as a possibly empty, pecent-encoded string.
///
Expand Down Expand Up @@ -405,7 +405,7 @@ impl<'a> UrlParser<'a> {


/// Determines the behavior of the URL parser for a given scheme.
#[derive(PartialEq, Eq, Copy, Show)]
#[derive(PartialEq, Eq, Copy, Debug)]
pub enum SchemeType {
/// Indicate that the scheme is *non-relative*.
///
Expand Down Expand Up @@ -768,7 +768,7 @@ impl rustc_serialize::Decodable for Url {
}


impl fmt::String for Url {
impl fmt::Display for Url {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
try!(UrlNoFragmentFormatter{ url: self }.fmt(formatter));
if let Some(ref fragment) = self.fragment {
Expand All @@ -780,7 +780,7 @@ impl fmt::String for Url {
}


impl fmt::String for SchemeData {
impl fmt::Display for SchemeData {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
match *self {
SchemeData::Relative(ref scheme_data) => scheme_data.fmt(formatter),
Expand Down Expand Up @@ -885,7 +885,7 @@ impl RelativeSchemeData {
}


impl fmt::String for RelativeSchemeData {
impl fmt::Display for RelativeSchemeData {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
// Write the scheme-trailing double slashes.
try!(formatter.write_str("//"));
Expand Down Expand Up @@ -940,7 +940,7 @@ impl ToUrlPath for path::windows::Path {
return Err(())
}
// Start with the prefix, e.g. "C:"
let mut path = vec![self.as_str().unwrap().slice_to(2).to_string()];
let mut path = vec![self.as_str().unwrap()[..2].to_string()];
// self.components() does not include the prefix
for component in self.components() {
path.push(percent_encode(component, DEFAULT_ENCODE_SET));
Expand Down
Loading