Skip to content

Commit bc05da8

Browse files
committed
Pleasing the 1.33.0 borrow checker.
1 parent 6db15ce commit bc05da8

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,8 @@ impl Url {
20412041
// If it is the scheme's default
20422042
// We don't mind it silently failing
20432043
// If there was no port in the first place
2044-
let _ = self.set_port(self.port());
2044+
let previous_port = self.port();
2045+
let _ = self.set_port(previous_port);
20452046

20462047
Ok(())
20472048
}

src/parser.rs

+16-13
Original file line numberDiff line numberDiff line change
@@ -1218,12 +1218,13 @@ impl<'a> Parser<'a> {
12181218
}
12191219
}
12201220
}
1221-
1222-
let segment_before_slash = if ends_with_slash {
1223-
&self.serialization[segment_start..self.serialization.len() - 1]
1221+
// Going from &str to String to &str to please the 1.33.0 borrow checker
1222+
let before_slash_string = if ends_with_slash {
1223+
self.serialization[segment_start..self.serialization.len() - 1].to_owned()
12241224
} else {
1225-
&self.serialization[segment_start..self.serialization.len()]
1225+
self.serialization[segment_start..self.serialization.len()].to_owned()
12261226
};
1227+
let segment_before_slash: &str = &before_slash_string;
12271228
match segment_before_slash {
12281229
// If buffer is a double-dot path segment, shorten url’s path,
12291230
".." | "%2e%2e" | "%2e%2E" | "%2E%2e" | "%2E%2E" | "%2e." | "%2E." | ".%2e"
@@ -1298,16 +1299,18 @@ impl<'a> Parser<'a> {
12981299
if self.serialization.len() <= path_start {
12991300
return;
13001301
}
1301-
// If url’s scheme is "file", path’s size is 1, and path[0] is a normalized Windows drive letter, then return.
1302-
let segments: Vec<&str> = self.serialization[path_start..]
1303-
.split('/')
1304-
.filter(|s| !s.is_empty())
1305-
.collect();
1306-
if scheme_type.is_file()
1307-
&& segments.len() == 1
1308-
&& is_normalized_windows_drive_letter(segments[0])
13091302
{
1310-
return;
1303+
// If url’s scheme is "file", path’s size is 1, and path[0] is a normalized Windows drive letter, then return.
1304+
let segments: Vec<&str> = self.serialization[path_start..]
1305+
.split('/')
1306+
.filter(|s| !s.is_empty())
1307+
.collect();
1308+
if scheme_type.is_file()
1309+
&& segments.len() == 1
1310+
&& is_normalized_windows_drive_letter(segments[0])
1311+
{
1312+
return;
1313+
}
13111314
}
13121315
// Remove path’s last item.
13131316
self.pop_path(scheme_type, path_start);

0 commit comments

Comments
 (0)