diff options
author | Richard Walters <rwalters@digitalstirling.com> | 2020-10-14 23:09:54 -0700 |
---|---|---|
committer | Richard Walters <rwalters@digitalstirling.com> | 2020-10-14 23:09:54 -0700 |
commit | 03b82171f70815e43fbc64d120a20e7a1eebd0bc (patch) | |
tree | 3d00526b97bee2b7b848ddf0c006788cd4f4924c /src/parse_host_port.rs | |
parent | 472c84a39a29bb9a2778cac67f5a9be78eca93bc (diff) |
Fix new clippy warnings
* Suppress clippy::option_if_let_else in
parse_host_port::State::next_percent_encoded_character
because the warning recommends Option::map_or which
we cannot use because it leads to using a moved value.
* Use matches! instead in uri::Uri::is_path_absolute as recommended.
* Use and_then instead of if let/else in uri::Uri::port as recommended;
note we need to replace the & with as_ref for self.authority.
* In uri::Uri::resolve, replace the large if let/else with map_or
as recommended, although it's not clear if it makes it any
easier to read. ¯\_(ツ)_/¯
Diffstat (limited to 'src/parse_host_port.rs')
-rw-r--r-- | src/parse_host_port.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/parse_host_port.rs b/src/parse_host_port.rs index e7d65c0..ae4a278 100644 --- a/src/parse_host_port.rs +++ b/src/parse_host_port.rs @@ -121,6 +121,11 @@ impl State{ fn next_percent_encoded_character(state: Shared, c: char) -> Result<Self, Error> { let mut state = state; + // We can't use `Option::map_or` (or `Option::map_or_else`, for similar + // reasons) in this case because the closure would take ownership of + // `state`, preventing it from being used to construct the default + // value. + #[allow(clippy::option_if_let_else)] if let Some(ci) = state.pec_decoder.next(c)? { state.host.push(ci); Ok(Self::NotIpLiteral(state)) |