diff options
| -rw-r--r-- | src/libstd/net_url.rs | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 70d8cf70497..855608a8fdf 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -1,4 +1,6 @@ //! Types/fns concerning URLs (see RFC 3986) +#[forbid(deprecated_mode)]; +#[forbid(deprecated_pattern)]; use core::cmp::Eq; use map::{hashmap, str_hash}; @@ -34,15 +36,16 @@ type UserInfo = { type Query = ~[(~str, ~str)]; -fn Url(-scheme: ~str, -user: Option<UserInfo>, -host: ~str, - -port: Option<~str>, -path: ~str, -query: Query, - -fragment: Option<~str>) -> Url { - Url { scheme: scheme, user: user, host: host, port: port, - path: path, query: query, fragment: fragment } +fn Url(+scheme: ~str, +user: Option<UserInfo>, +host: ~str, + +port: Option<~str>, +path: ~str, +query: Query, + +fragment: Option<~str>) -> Url { + Url { scheme: move scheme, user: move user, host: move host, + port: move port, path: move path, query: move query, + fragment: move fragment } } -fn UserInfo(-user: ~str, -pass: Option<~str>) -> UserInfo { - {user: user, pass: pass} +fn UserInfo(+user: ~str, +pass: Option<~str>) -> UserInfo { + {user: move user, pass: move pass} } fn encode_inner(s: &str, full_url: bool) -> ~str { @@ -104,7 +107,7 @@ fn encode_component(s: &str) -> ~str { encode_inner(s, false) } -fn decode_inner(s: ~str, full_url: bool) -> ~str { +fn decode_inner(s: &str, full_url: bool) -> ~str { do io::with_str_reader(s) |rdr| { let mut out = ~""; @@ -147,18 +150,18 @@ fn decode_inner(s: ~str, full_url: bool) -> ~str { * * This will only decode escape sequences generated by encode_uri. */ -fn decode(s: ~str) -> ~str { +fn decode(s: &str) -> ~str { decode_inner(s, true) } /** * Decode a string encoded with percent encoding. */ -fn decode_component(s: ~str) -> ~str { +fn decode_component(s: &str) -> ~str { decode_inner(s, false) } -fn encode_plus(s: ~str) -> ~str { +fn encode_plus(s: &str) -> ~str { do io::with_str_reader(s) |rdr| { let mut out = ~""; @@ -269,7 +272,7 @@ fn decode_form_urlencoded(s: ~[u8]) -> } -fn split_char_first(s: ~str, c: char) -> (~str, ~str) { +fn split_char_first(s: &str, c: char) -> (~str, ~str) { let len = str::len(s); let mut index = len; let mut mat = 0; @@ -293,7 +296,7 @@ fn split_char_first(s: ~str, c: char) -> (~str, ~str) { } } -fn userinfo_from_str(uinfo: ~str) -> UserInfo { +fn userinfo_from_str(uinfo: &str) -> UserInfo { let (user, p) = split_char_first(uinfo, ':'); let pass = if str::len(p) == 0 { option::None @@ -303,7 +306,7 @@ fn userinfo_from_str(uinfo: ~str) -> UserInfo { return UserInfo(user, pass); } -fn userinfo_to_str(-userinfo: UserInfo) -> ~str { +fn userinfo_to_str(+userinfo: UserInfo) -> ~str { if option::is_some(userinfo.pass) { return str::concat(~[copy userinfo.user, ~":", option::unwrap(copy userinfo.pass), @@ -319,7 +322,7 @@ impl UserInfo : Eq { } } -fn query_from_str(rawquery: ~str) -> Query { +fn query_from_str(rawquery: &str) -> Query { let mut query: Query = ~[]; if str::len(rawquery) != 0 { for str::split_char(rawquery, '&').each |p| { @@ -330,7 +333,7 @@ fn query_from_str(rawquery: ~str) -> Query { return query; } -fn query_to_str(query: Query) -> ~str { +fn query_to_str(+query: Query) -> ~str { let mut strvec = ~[]; for query.each |kv| { let (k, v) = copy kv; @@ -676,7 +679,7 @@ impl Url : FromStr { * result in just "http://somehost.com". * */ -fn to_str(url: Url) -> ~str { +fn to_str(+url: Url) -> ~str { let user = if option::is_some(url.user) { userinfo_to_str(option::unwrap(copy url.user)) } else { |
