Skip to content

Commit 6b029c6

Browse files
committed
MSRV 1.36 + fmt
1 parent e398b2c commit 6b029c6

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

url/src/lib.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,8 @@ impl Url {
13611361
}
13621362

13631363
fn mutate<F: FnOnce(&mut Parser<'_>) -> R, R>(&mut self, f: F) -> R {
1364-
let mut parser = Parser::for_setter(mem::take(&mut self.serialization));
1364+
#[allow(clippy::mem_replace_with_default)] // introduced in 1.40, MSRV is 1.36
1365+
let mut parser = Parser::for_setter(mem::replace(&mut self.serialization, String::new()));
13651366
let result = f(&mut parser);
13661367
self.serialization = parser.serialization;
13671368
result
@@ -1551,19 +1552,19 @@ impl Url {
15511552
/// url.set_path("data/report.csv");
15521553
/// assert_eq!(url.as_str(), "https://example.com/data/report.csv");
15531554
/// assert_eq!(url.path(), "/data/report.csv");
1554-
///
1555+
///
15551556
/// // `set_path` percent-encodes the given string if it's not already percent-encoded.
15561557
/// let mut url = Url::parse("https://example.com")?;
15571558
/// url.set_path("api/some comments");
15581559
/// assert_eq!(url.as_str(), "https://example.com/api/some%20comments");
15591560
/// assert_eq!(url.path(), "/api/some%20comments");
1560-
///
1561+
///
15611562
/// // `set_path` will not double percent-encode the string if it's already percent-encoded.
15621563
/// let mut url = Url::parse("https://example.com")?;
15631564
/// url.set_path("api/some%20comments");
15641565
/// assert_eq!(url.as_str(), "https://example.com/api/some%20comments");
15651566
/// assert_eq!(url.path(), "/api/some%20comments");
1566-
///
1567+
///
15671568
/// # Ok(())
15681569
/// # }
15691570
/// # run().unwrap();
@@ -2684,9 +2685,9 @@ fn path_to_file_url_segments(
26842685
path: &Path,
26852686
serialization: &mut String,
26862687
) -> Result<(u32, HostInternal), ()> {
2687-
#[cfg(any(unix, target_os = "redox"))]
2688+
#[cfg(any(unix, target_os = "redox"))]
26882689
use std::os::unix::prelude::OsStrExt;
2689-
#[cfg(target_os = "wasi")]
2690+
#[cfg(target_os = "wasi")]
26902691
use std::os::wasi::prelude::OsStrExt;
26912692
if !path.is_absolute() {
26922693
return Err(());
@@ -2783,9 +2784,9 @@ fn file_url_segments_to_pathbuf(
27832784
segments: str::Split<'_, char>,
27842785
) -> Result<PathBuf, ()> {
27852786
use std::ffi::OsStr;
2786-
#[cfg(any(unix, target_os = "redox"))]
2787+
#[cfg(any(unix, target_os = "redox"))]
27872788
use std::os::unix::prelude::OsStrExt;
2788-
#[cfg(target_os = "wasi")]
2789+
#[cfg(target_os = "wasi")]
27892790
use std::os::wasi::prelude::OsStrExt;
27902791

27912792
if host.is_some() {

url/src/quirks.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,10 @@ pub fn set_host(url: &mut Url, new_host: &str) -> Result<(), ()> {
139139
}
140140
}
141141
// Make sure we won't set an empty host to a url with a username or a port
142-
if host == Host::Domain("".to_string()) && (!username(url).is_empty() || matches!(opt_port, Some(Some(_))) || url.port().is_some()) {
143-
return Err(());
142+
if host == Host::Domain("".to_string())
143+
&& (!username(url).is_empty() || matches!(opt_port, Some(Some(_))) || url.port().is_some())
144+
{
145+
return Err(());
144146
}
145147
url.set_host_internal(host, opt_port);
146148
Ok(())

0 commit comments

Comments
 (0)