@@ -65,9 +65,9 @@ impl Url {
65
65
// query and fragment
66
66
let ( query, fragment) = try!( get_query_fragment ( rest) ) ;
67
67
68
- let url = Url :: new ( scheme. to_string ( ) ,
68
+ let url = Url :: new ( scheme. to_owned ( ) ,
69
69
userinfo,
70
- host. to_string ( ) ,
70
+ host. to_owned ( ) ,
71
71
port,
72
72
path,
73
73
query,
@@ -180,22 +180,22 @@ pub fn get_scheme(rawurl: &str) -> DecodeResult<(&str, &str)> {
180
180
'0' ... '9' | '+' | '-' | '.' => {
181
181
if i != 0 { continue }
182
182
183
- Err ( "url: Scheme must begin with a letter." . to_string ( ) )
183
+ Err ( "url: Scheme must begin with a letter." . to_owned ( ) )
184
184
}
185
185
':' => {
186
186
if i == 0 {
187
- Err ( "url: Scheme cannot be empty." . to_string ( ) )
187
+ Err ( "url: Scheme cannot be empty." . to_owned ( ) )
188
188
} else {
189
189
Ok ( ( & rawurl[ 0 ..i] , & rawurl[ i+1 ..rawurl. len ( ) ] ) )
190
190
}
191
191
}
192
- _ => Err ( "url: Invalid character in scheme." . to_string ( ) ) ,
192
+ _ => Err ( "url: Invalid character in scheme." . to_owned ( ) ) ,
193
193
} ;
194
194
195
195
return result;
196
196
}
197
197
198
- Err ( "url: Scheme must be terminated with a colon." . to_string ( ) )
198
+ Err ( "url: Scheme must be terminated with a colon." . to_owned ( ) )
199
199
}
200
200
201
201
// returns userinfo, host, port, and unparsed part, or an error
@@ -255,7 +255,7 @@ fn get_authority(rawurl: &str) ->
255
255
':' | '@' | '?' | '#' | '/' => {
256
256
// separators, don't change anything
257
257
}
258
- _ => return Err ( "Illegal character in authority" . to_string ( ) ) ,
258
+ _ => return Err ( "Illegal character in authority" . to_owned ( ) ) ,
259
259
}
260
260
261
261
// now process states
@@ -271,7 +271,7 @@ fn get_authority(rawurl: &str) ->
271
271
// multiple colons means ipv6 address.
272
272
if input == Input :: Unreserved {
273
273
return Err (
274
- "Illegal characters in IPv6 address." . to_string ( ) ) ;
274
+ "Illegal characters in IPv6 address." . to_owned ( ) ) ;
275
275
}
276
276
st = State :: Ip6Host ;
277
277
}
@@ -288,7 +288,7 @@ fn get_authority(rawurl: &str) ->
288
288
}
289
289
State :: Ip6Port => {
290
290
if input == Input :: Unreserved {
291
- return Err ( "Illegal characters in authority." . to_string ( ) ) ;
291
+ return Err ( "Illegal characters in authority." . to_owned ( ) ) ;
292
292
}
293
293
st = State :: Ip6Host ;
294
294
}
@@ -299,7 +299,7 @@ fn get_authority(rawurl: &str) ->
299
299
st = State :: InPort ;
300
300
}
301
301
}
302
- _ => return Err ( "Invalid ':' in authority." . to_string ( ) ) ,
302
+ _ => return Err ( "Invalid ':' in authority." . to_owned ( ) ) ,
303
303
}
304
304
input = Input :: Digit ; // reset input class
305
305
}
@@ -319,7 +319,7 @@ fn get_authority(rawurl: &str) ->
319
319
userinfo = Some ( UserInfo :: new ( user, Some ( pass) ) ) ;
320
320
st = State :: InHost ;
321
321
}
322
- _ => return Err ( "Invalid '@' in authority." . to_string ( ) ) ,
322
+ _ => return Err ( "Invalid '@' in authority." . to_owned ( ) ) ,
323
323
}
324
324
begin = i+1 ;
325
325
}
@@ -338,7 +338,7 @@ fn get_authority(rawurl: &str) ->
338
338
State :: PassHostPort
339
339
| State :: Ip6Port => {
340
340
if input != Input :: Digit {
341
- return Err ( "Non-digit characters in port." . to_string ( ) ) ;
341
+ return Err ( "Non-digit characters in port." . to_owned ( ) ) ;
342
342
}
343
343
host = & rawurl[ begin..pos] ;
344
344
port = Some ( & rawurl[ pos+1 ..end] ) ;
@@ -347,7 +347,7 @@ fn get_authority(rawurl: &str) ->
347
347
| State :: InHost => host = & rawurl[ begin..end] ,
348
348
State :: InPort => {
349
349
if input != Input :: Digit {
350
- return Err ( "Non-digit characters in port." . to_string ( ) ) ;
350
+ return Err ( "Non-digit characters in port." . to_owned ( ) ) ;
351
351
}
352
352
port = Some ( & rawurl[ pos+1 ..end] ) ;
353
353
}
@@ -384,13 +384,13 @@ fn get_path(rawurl: &str, is_authority: bool) -> DecodeResult<(String, &str)> {
384
384
end = i;
385
385
break ;
386
386
}
387
- _ => return Err ( "Invalid character in path." . to_string ( ) )
387
+ _ => return Err ( "Invalid character in path." . to_owned ( ) )
388
388
}
389
389
}
390
390
391
391
if is_authority && end != 0 && !rawurl. starts_with ( "/" ) {
392
392
Err ( "Non-empty path must begin with \
393
- '/' in presence of authority.". to_string ( ) )
393
+ '/' in presence of authority.". to_owned ( ) )
394
394
} else {
395
395
Ok ( ( try!( decode_component ( & rawurl[ 0 ..end] ) ) , & rawurl[ end..len] ) )
396
396
}
0 commit comments