diff --git a/src/client/mod.rs b/src/client/mod.rs index 57e27883..04bd8ef4 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -381,7 +381,7 @@ mod tests { client.set_redirect_policy(RedirectPolicy::FollowAll); let res = client.get("http://127.0.0.1").send().unwrap(); - assert_eq!(res.headers.get(), Some(&Server("mock3".into_string()))); + assert_eq!(res.headers.get(), Some(&Server("mock3".to_string()))); } #[test] @@ -389,7 +389,7 @@ mod tests { let mut client = Client::with_connector(MockRedirectPolicy); client.set_redirect_policy(RedirectPolicy::FollowNone); let res = client.get("http://127.0.0.1").send().unwrap(); - assert_eq!(res.headers.get(), Some(&Server("mock1".into_string()))); + assert_eq!(res.headers.get(), Some(&Server("mock1".to_string()))); } #[test] @@ -400,7 +400,7 @@ mod tests { let mut client = Client::with_connector(MockRedirectPolicy); client.set_redirect_policy(RedirectPolicy::FollowIf(follow_if)); let res = client.get("http://127.0.0.1").send().unwrap(); - assert_eq!(res.headers.get(), Some(&Server("mock2".into_string()))); + assert_eq!(res.headers.get(), Some(&Server("mock2".to_string()))); } } diff --git a/src/header/common/accept.rs b/src/header/common/accept.rs index 1a9580a0..bfa847ff 100644 --- a/src/header/common/accept.rs +++ b/src/header/common/accept.rs @@ -36,7 +36,7 @@ impl Header for Accept { match from_utf8(mimes_raw.as_slice()) { Ok(mimes_str) => { for mime_str in mimes_str.split(',') { - match from_str(mime_str.trim()) { + match mime_str.trim().parse() { Some(mime) => mimes.push(mime), None => return None } diff --git a/src/header/common/authorization.rs b/src/header/common/authorization.rs index 99fdf505..0b953f8f 100644 --- a/src/header/common/authorization.rs +++ b/src/header/common/authorization.rs @@ -29,9 +29,9 @@ impl Header for Authorization { match (from_utf8(unsafe { raw[].unsafe_get(0)[] }), Scheme::scheme(None::)) { (Ok(header), Some(scheme)) if header.starts_with(scheme) && header.len() > scheme.len() + 1 => { - from_str::(header[scheme.len() + 1..]).map(|s| Authorization(s)) + header[scheme.len() + 1..].parse::().map(|s| Authorization(s)) }, - (Ok(header), None) => from_str::(header).map(|s| Authorization(s)), + (Ok(header), None) => header.parse::().map(|s| Authorization(s)), _ => None } } else { @@ -111,11 +111,11 @@ impl FromStr for Basic { Ok(text) => { let mut parts = text[].split(':'); let user = match parts.next() { - Some(part) => part.into_string(), + Some(part) => part.to_string(), None => return None }; let password = match parts.next() { - Some(part) => Some(part.into_string()), + Some(part) => Some(part.to_string()), None => None }; Some(Basic { @@ -149,7 +149,7 @@ mod tests { #[test] fn test_raw_auth() { let mut headers = Headers::new(); - headers.set(Authorization("foo bar baz".into_string())); + headers.set(Authorization("foo bar baz".to_string())); assert_eq!(headers.to_string(), "Authorization: foo bar baz\r\n".to_string()); } @@ -162,8 +162,8 @@ mod tests { #[test] fn test_basic_auth() { let mut headers = Headers::new(); - headers.set(Authorization(Basic { username: "Aladdin".into_string(), password: Some("open sesame".into_string()) })); - assert_eq!(headers.to_string(), "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\r\n".into_string()); + headers.set(Authorization(Basic { username: "Aladdin".to_string(), password: Some("open sesame".to_string()) })); + assert_eq!(headers.to_string(), "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\r\n".to_string()); } #[test] diff --git a/src/header/common/cache_control.rs b/src/header/common/cache_control.rs index 1844c82b..83e04b08 100644 --- a/src/header/common/cache_control.rs +++ b/src/header/common/cache_control.rs @@ -110,14 +110,14 @@ impl FromStr for CacheDirective { "" => None, _ => match s.find('=') { Some(idx) if idx+1 < s.len() => match (s[..idx], s[idx+1..].trim_chars('"')) { - ("max-age" , secs) => from_str::(secs).map(MaxAge), - ("max-stale", secs) => from_str::(secs).map(MaxStale), - ("min-fresh", secs) => from_str::(secs).map(MinFresh), - ("s-maxage", secs) => from_str::(secs).map(SMaxAge), - (left, right) => Some(Extension(left.into_string(), Some(right.into_string()))) + ("max-age" , secs) => secs.parse().map(MaxAge), + ("max-stale", secs) => secs.parse().map(MaxStale), + ("min-fresh", secs) => secs.parse().map(MinFresh), + ("s-maxage", secs) => secs.parse().map(SMaxAge), + (left, right) => Some(Extension(left.to_string(), Some(right.to_string()))) }, Some(_) => None, - None => Some(Extension(s.into_string(), None)) + None => Some(Extension(s.to_string(), None)) } } } diff --git a/src/header/common/cookie.rs b/src/header/common/cookie.rs index 3496d000..46b53d82 100644 --- a/src/header/common/cookie.rs +++ b/src/header/common/cookie.rs @@ -1,6 +1,6 @@ use header::{Header, HeaderFormat}; use std::fmt::{mod, Show}; -use std::str::{from_utf8, from_str}; +use std::str::from_utf8; use cookie::Cookie; use cookie::CookieJar; @@ -29,7 +29,7 @@ impl Header for Cookies { match from_utf8(cookies_raw[]) { Ok(cookies_str) => { for cookie_str in cookies_str.split(';') { - match from_str(cookie_str.trim()) { + match cookie_str.trim().parse() { Some(cookie) => cookies.push(cookie), None => return None } diff --git a/src/header/common/etag.rs b/src/header/common/etag.rs index 74a355d3..bddbf02e 100644 --- a/src/header/common/etag.rs +++ b/src/header/common/etag.rs @@ -55,7 +55,7 @@ impl Header for Etag { if check_slice_validity(slice.slice_chars(1, length-1)) { return Some(Etag { weak: false, - tag: slice.slice_chars(1, length-1).into_string() + tag: slice.slice_chars(1, length-1).to_string() }); } else { return None; @@ -66,7 +66,7 @@ impl Header for Etag { if check_slice_validity(slice.slice_chars(3, length-1)) { return Some(Etag { weak: true, - tag: slice.slice_chars(3, length-1).into_string() + tag: slice.slice_chars(3, length-1).to_string() }); } else { return None; @@ -100,31 +100,31 @@ mod tests { etag = Header::parse_header([b"\"foobar\"".to_vec()].as_slice()); assert_eq!(etag, Some(Etag { weak: false, - tag: "foobar".into_string() + tag: "foobar".to_string() })); etag = Header::parse_header([b"\"\"".to_vec()].as_slice()); assert_eq!(etag, Some(Etag { weak: false, - tag: "".into_string() + tag: "".to_string() })); etag = Header::parse_header([b"W/\"weak-etag\"".to_vec()].as_slice()); assert_eq!(etag, Some(Etag { weak: true, - tag: "weak-etag".into_string() + tag: "weak-etag".to_string() })); etag = Header::parse_header([b"W/\"\x65\x62\"".to_vec()].as_slice()); assert_eq!(etag, Some(Etag { weak: true, - tag: "\u{0065}\u{0062}".into_string() + tag: "\u{0065}\u{0062}".to_string() })); etag = Header::parse_header([b"W/\"\"".to_vec()].as_slice()); assert_eq!(etag, Some(Etag { weak: true, - tag: "".into_string() + tag: "".to_string() })); } diff --git a/src/header/common/host.rs b/src/header/common/host.rs index dd1554e9..3f14d658 100644 --- a/src/header/common/host.rs +++ b/src/header/common/host.rs @@ -46,7 +46,7 @@ impl Header for Host { }; let port = match idx { - Some(idx) => from_str::(s[].slice_from(idx + 1)), + Some(idx) => s[].slice_from(idx + 1).parse(), None => None }; @@ -82,14 +82,14 @@ mod tests { fn test_host() { let host = Header::parse_header([b"foo.com".to_vec()].as_slice()); assert_eq!(host, Some(Host { - hostname: "foo.com".into_string(), + hostname: "foo.com".to_string(), port: None })); let host = Header::parse_header([b"foo.com:8080".to_vec()].as_slice()); assert_eq!(host, Some(Host { - hostname: "foo.com".into_string(), + hostname: "foo.com".to_string(), port: Some(8080) })); } diff --git a/src/header/common/set_cookie.rs b/src/header/common/set_cookie.rs index ea7b6212..faa50f51 100644 --- a/src/header/common/set_cookie.rs +++ b/src/header/common/set_cookie.rs @@ -25,7 +25,7 @@ impl Header for SetCookie { for set_cookies_raw in raw.iter() { match from_utf8(set_cookies_raw[]) { Ok(s) if !s.is_empty() => { - match from_str(s) { + match s.parse() { Some(cookie) => set_cookies.push(cookie), None => () } diff --git a/src/header/common/util.rs b/src/header/common/util.rs index 5cb69961..0d272463 100644 --- a/src/header/common/util.rs +++ b/src/header/common/util.rs @@ -32,7 +32,7 @@ pub fn from_one_comma_delimited(raw: &[u8]) -> Option> { Ok(s) => { Some(s.as_slice() .split([',', ' '].as_slice()) - .filter_map(from_str) + .filter_map(FromStr::from_str) .collect()) } Err(_) => None diff --git a/src/header/mod.rs b/src/header/mod.rs index a483139a..256e69a9 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -620,7 +620,7 @@ mod tests { fn test_headers_show() { let mut headers = Headers::new(); headers.set(ContentLength(15)); - headers.set(Host { hostname: "foo.bar".into_string(), port: None }); + headers.set(Host { hostname: "foo.bar".to_string(), port: None }); let s = headers.to_string(); // hashmap's iterators have arbitrary order, so we must sort first diff --git a/src/http.rs b/src/http.rs index e62dff16..d2809ce5 100644 --- a/src/http.rs +++ b/src/http.rs @@ -4,7 +4,7 @@ use std::cmp::min; use std::fmt; use std::io::{mod, Reader, IoResult, BufWriter}; use std::num::from_u16; -use std::str::{mod, SendStr}; +use std::str::{mod, SendStr, FromStr}; use url::Url; use url::ParseError as UrlError; @@ -260,7 +260,7 @@ impl Writer for HttpWriter { Err(io::IoError { kind: io::ShortWrite(bytes), desc: "EmptyWriter cannot write any bytes", - detail: Some("Cannot include a body with this kind of message".into_string()) + detail: Some("Cannot include a body with this kind of message".to_string()) }) } } @@ -397,7 +397,7 @@ pub fn read_method(stream: &mut R) -> HttpResult { (Some(method), _) => Ok(method), (None, ext) => { // We already checked that the buffer is ASCII - Ok(method::Method::Extension(unsafe { str::from_utf8_unchecked(ext) }.trim().into_string())) + Ok(method::Method::Extension(unsafe { str::from_utf8_unchecked(ext) }.trim().to_string())) }, } } @@ -622,7 +622,7 @@ pub fn read_status(stream: &mut R) -> HttpResult { try!(stream.read_byte()), ]; - let code = match str::from_utf8(code.as_slice()).ok().and_then(from_str::) { + let code = match str::from_utf8(code.as_slice()).ok().and_then(FromStr::from_str) { Some(num) => num, None => return Err(HttpStatusError) }; @@ -672,10 +672,10 @@ pub fn read_status(stream: &mut R) -> HttpResult { if phrase == reason { Borrowed(phrase) } else { - Owned(reason.into_string()) + Owned(reason.to_string()) } } - _ => Owned(reason.into_string()) + _ => Owned(reason.to_string()) }, None => return Err(HttpStatusError) }; diff --git a/src/server/mod.rs b/src/server/mod.rs index 3f338b2b..1eb6ad41 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -68,7 +68,7 @@ impl, S: NetworkStream, A: NetworkAcceptor> Server