Skip to content

Commit d072bc0

Browse files
killerswanbrson
authored andcommitted
Demode libstd/net_url.rs
1 parent 9c8b0c6 commit d072bc0

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

src/libstd/net_url.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//! Types/fns concerning URLs (see RFC 3986)
2+
#[forbid(deprecated_mode)];
3+
#[forbid(deprecated_pattern)];
24

35
use core::cmp::Eq;
46
use map::{hashmap, str_hash};
@@ -34,15 +36,16 @@ type UserInfo = {
3436

3537
type Query = ~[(~str, ~str)];
3638

37-
fn Url(-scheme: ~str, -user: Option<UserInfo>, -host: ~str,
38-
-port: Option<~str>, -path: ~str, -query: Query,
39-
-fragment: Option<~str>) -> Url {
40-
Url { scheme: scheme, user: user, host: host, port: port,
41-
path: path, query: query, fragment: fragment }
39+
fn Url(+scheme: ~str, +user: Option<UserInfo>, +host: ~str,
40+
+port: Option<~str>, +path: ~str, +query: Query,
41+
+fragment: Option<~str>) -> Url {
42+
Url { scheme: move scheme, user: move user, host: move host,
43+
port: move port, path: move path, query: move query,
44+
fragment: move fragment }
4245
}
4346

44-
fn UserInfo(-user: ~str, -pass: Option<~str>) -> UserInfo {
45-
{user: user, pass: pass}
47+
fn UserInfo(+user: ~str, +pass: Option<~str>) -> UserInfo {
48+
{user: move user, pass: move pass}
4649
}
4750

4851
fn encode_inner(s: &str, full_url: bool) -> ~str {
@@ -104,7 +107,7 @@ fn encode_component(s: &str) -> ~str {
104107
encode_inner(s, false)
105108
}
106109

107-
fn decode_inner(s: ~str, full_url: bool) -> ~str {
110+
fn decode_inner(s: &str, full_url: bool) -> ~str {
108111
do io::with_str_reader(s) |rdr| {
109112
let mut out = ~"";
110113

@@ -147,18 +150,18 @@ fn decode_inner(s: ~str, full_url: bool) -> ~str {
147150
*
148151
* This will only decode escape sequences generated by encode_uri.
149152
*/
150-
fn decode(s: ~str) -> ~str {
153+
fn decode(s: &str) -> ~str {
151154
decode_inner(s, true)
152155
}
153156

154157
/**
155158
* Decode a string encoded with percent encoding.
156159
*/
157-
fn decode_component(s: ~str) -> ~str {
160+
fn decode_component(s: &str) -> ~str {
158161
decode_inner(s, false)
159162
}
160163

161-
fn encode_plus(s: ~str) -> ~str {
164+
fn encode_plus(s: &str) -> ~str {
162165
do io::with_str_reader(s) |rdr| {
163166
let mut out = ~"";
164167

@@ -269,7 +272,7 @@ fn decode_form_urlencoded(s: ~[u8]) ->
269272
}
270273

271274

272-
fn split_char_first(s: ~str, c: char) -> (~str, ~str) {
275+
fn split_char_first(s: &str, c: char) -> (~str, ~str) {
273276
let len = str::len(s);
274277
let mut index = len;
275278
let mut mat = 0;
@@ -293,7 +296,7 @@ fn split_char_first(s: ~str, c: char) -> (~str, ~str) {
293296
}
294297
}
295298

296-
fn userinfo_from_str(uinfo: ~str) -> UserInfo {
299+
fn userinfo_from_str(uinfo: &str) -> UserInfo {
297300
let (user, p) = split_char_first(uinfo, ':');
298301
let pass = if str::len(p) == 0 {
299302
option::None
@@ -303,7 +306,7 @@ fn userinfo_from_str(uinfo: ~str) -> UserInfo {
303306
return UserInfo(user, pass);
304307
}
305308

306-
fn userinfo_to_str(-userinfo: UserInfo) -> ~str {
309+
fn userinfo_to_str(+userinfo: UserInfo) -> ~str {
307310
if option::is_some(userinfo.pass) {
308311
return str::concat(~[copy userinfo.user, ~":",
309312
option::unwrap(copy userinfo.pass),
@@ -319,7 +322,7 @@ impl UserInfo : Eq {
319322
}
320323
}
321324

322-
fn query_from_str(rawquery: ~str) -> Query {
325+
fn query_from_str(rawquery: &str) -> Query {
323326
let mut query: Query = ~[];
324327
if str::len(rawquery) != 0 {
325328
for str::split_char(rawquery, '&').each |p| {
@@ -330,7 +333,7 @@ fn query_from_str(rawquery: ~str) -> Query {
330333
return query;
331334
}
332335

333-
fn query_to_str(query: Query) -> ~str {
336+
fn query_to_str(+query: Query) -> ~str {
334337
let mut strvec = ~[];
335338
for query.each |kv| {
336339
let (k, v) = copy kv;
@@ -676,7 +679,7 @@ impl Url : FromStr {
676679
* result in just "http://somehost.com".
677680
*
678681
*/
679-
fn to_str(url: Url) -> ~str {
682+
fn to_str(+url: Url) -> ~str {
680683
let user = if option::is_some(url.user) {
681684
userinfo_to_str(option::unwrap(copy url.user))
682685
} else {

0 commit comments

Comments
 (0)