Skip to content

Commit 8dd3dbd

Browse files
committed
Pleasing the 1.33.0 borrow checker.
1 parent a48dbc3 commit 8dd3dbd

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
@@ -2097,7 +2097,8 @@ impl Url {
20972097
// If it is the scheme's default
20982098
// We don't mind it silently failing
20992099
// If there was no port in the first place
2100-
let _ = self.set_port(self.port());
2100+
let previous_port = self.port();
2101+
let _ = self.set_port(previous_port);
21012102

21022103
Ok(())
21032104
}

src/parser.rs

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

0 commit comments

Comments
 (0)