Skip to content

Commit

Permalink
Replace is_some_and with map_or for MSRV
Browse files Browse the repository at this point in the history
is_some_and is stable only in Rust 1.70.0 and greater.

map_or(false, |s| s.eq_ignore_ascii_case(SCHEME)):
  - This method is used to handle the Option returned by get().
  - If get() returns None (i.e., the string is too short), map_or()
    returns false.
  - If get() returns Some(s), it applies the closure
    |s| s.eq_ignore_ascii_case(SCHEME).
     - This closure checks if the substring s is equal to SCHEME,
       ignoring ASCII case differences.
     - If they are equal, it returns true; otherwise, it returns
       false.
  • Loading branch information
DanGould committed Dec 2, 2024
1 parent 76244b1 commit 59f464c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl<'a, T: DeserializeParams<'a>> Uri<'a, bitcoin::address::NetworkUnchecked, T
return Err(Error::Uri(UriError(UriErrorInner::TooShort)));
}

if !string.get(..SCHEME.len()).is_some_and(|s| s.eq_ignore_ascii_case(SCHEME)) {
if !string.get(..SCHEME.len()).map_or(false, |s| s.eq_ignore_ascii_case(SCHEME)) {
return Err(Error::Uri(UriError(UriErrorInner::InvalidScheme)));
}

Expand Down

0 comments on commit 59f464c

Please sign in to comment.