Skip to content

Commit 63c69e8

Browse files
committed
Pleasing the 1.33.0 borrow checker.
1 parent 892f3d4 commit 63c69e8

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
@@ -2102,7 +2102,8 @@ impl Url {
21022102
// If it is the scheme's default
21032103
// We don't mind it silently failing
21042104
// If there was no port in the first place
2105-
let _ = self.set_port(self.port());
2105+
let previous_port = self.port();
2106+
let _ = self.set_port(previous_port);
21062107

21072108
Ok(())
21082109
}

src/parser.rs

+16-13
Original file line numberDiff line numberDiff line change
@@ -1235,12 +1235,13 @@ impl<'a> Parser<'a> {
12351235
}
12361236
}
12371237
}
1238-
1239-
let segment_before_slash = if ends_with_slash {
1240-
&self.serialization[segment_start..self.serialization.len() - 1]
1238+
// Going from &str to String to &str to please the 1.33.0 borrow checker
1239+
let before_slash_string = if ends_with_slash {
1240+
self.serialization[segment_start..self.serialization.len() - 1].to_owned()
12411241
} else {
1242-
&self.serialization[segment_start..self.serialization.len()]
1242+
self.serialization[segment_start..self.serialization.len()].to_owned()
12431243
};
1244+
let segment_before_slash: &str = &before_slash_string;
12441245
match segment_before_slash {
12451246
// If buffer is a double-dot path segment, shorten url’s path,
12461247
".." | "%2e%2e" | "%2e%2E" | "%2E%2e" | "%2E%2E" | "%2e." | "%2E." | ".%2e"
@@ -1315,16 +1316,18 @@ impl<'a> Parser<'a> {
13151316
if self.serialization.len() <= path_start {
13161317
return;
13171318
}
1318-
// If url’s scheme is "file", path’s size is 1, and path[0] is a normalized Windows drive letter, then return.
1319-
let segments: Vec<&str> = self.serialization[path_start..]
1320-
.split('/')
1321-
.filter(|s| !s.is_empty())
1322-
.collect();
1323-
if scheme_type.is_file()
1324-
&& segments.len() == 1
1325-
&& is_normalized_windows_drive_letter(segments[0])
13261319
{
1327-
return;
1320+
// If url’s scheme is "file", path’s size is 1, and path[0] is a normalized Windows drive letter, then return.
1321+
let segments: Vec<&str> = self.serialization[path_start..]
1322+
.split('/')
1323+
.filter(|s| !s.is_empty())
1324+
.collect();
1325+
if scheme_type.is_file()
1326+
&& segments.len() == 1
1327+
&& is_normalized_windows_drive_letter(segments[0])
1328+
{
1329+
return;
1330+
}
13281331
}
13291332
// Remove path’s last item.
13301333
self.pop_path(scheme_type, path_start);

0 commit comments

Comments
 (0)