Skip to content

Commit a9ca033

Browse files
committed
Pleasing the 1.33.0 borrow checker.
1 parent 736d7bc commit a9ca033

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2101,7 +2101,8 @@ impl Url {
21012101
// If it is the scheme's default
21022102
// We don't mind it silently failing
21032103
// If there was no port in the first place
2104-
let _ = self.set_port(self.port());
2104+
let previous_port = self.port();
2105+
let _ = self.set_port(previous_port);
21052106

21062107
Ok(())
21072108
}

src/parser.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,12 +1229,13 @@ impl<'a> Parser<'a> {
12291229
}
12301230
}
12311231
}
1232-
1233-
let segment_before_slash = if ends_with_slash {
1234-
&self.serialization[segment_start..self.serialization.len() - 1]
1232+
// Going from &str to String to &str to please the 1.33.0 borrow checker
1233+
let before_slash_string = if ends_with_slash {
1234+
self.serialization[segment_start..self.serialization.len() - 1].to_owned()
12351235
} else {
1236-
&self.serialization[segment_start..self.serialization.len()]
1236+
self.serialization[segment_start..self.serialization.len()].to_owned()
12371237
};
1238+
let segment_before_slash: &str = &before_slash_string;
12381239
match segment_before_slash {
12391240
// If buffer is a double-dot path segment, shorten url’s path,
12401241
".." | "%2e%2e" | "%2e%2E" | "%2E%2e" | "%2E%2E" | "%2e." | "%2E." | ".%2e"
@@ -1307,16 +1308,18 @@ impl<'a> Parser<'a> {
13071308
if self.serialization.len() == path_start {
13081309
return;
13091310
}
1310-
// If url’s scheme is "file", path’s size is 1, and path[0] is a normalized Windows drive letter, then return.
1311-
let segments: Vec<&str> = self.serialization[path_start..]
1312-
.split('/')
1313-
.filter(|s| !s.is_empty())
1314-
.collect();
1315-
if scheme_type.is_file()
1316-
&& segments.len() == 1
1317-
&& is_normalized_windows_drive_letter(segments[0])
13181311
{
1319-
return;
1312+
// If url’s scheme is "file", path’s size is 1, and path[0] is a normalized Windows drive letter, then return.
1313+
let segments: Vec<&str> = self.serialization[path_start..]
1314+
.split('/')
1315+
.filter(|s| !s.is_empty())
1316+
.collect();
1317+
if scheme_type.is_file()
1318+
&& segments.len() == 1
1319+
&& is_normalized_windows_drive_letter(segments[0])
1320+
{
1321+
return;
1322+
}
13201323
}
13211324
// Remove path’s last item.
13221325
self.pop_path(scheme_type, path_start);

0 commit comments

Comments
 (0)