Skip to content

Commit be1a4ee

Browse files
committed
Use ok_or_else instead of ok_or
Clippy emits: warning: use of `ok_or` followed by a function call As suggested, use `ok_or_else` with a closure.
1 parent 8944ca0 commit be1a4ee

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/descriptor/checksum.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ pub fn desc_checksum(desc: &str) -> Result<String, Error> {
4343
let mut clscount = 0;
4444

4545
for ch in desc.chars() {
46-
let pos = INPUT_CHARSET.find(ch).ok_or(Error::BadDescriptor(format!(
47-
"Invalid character in checksum: '{}'",
48-
ch
49-
)))? as u64;
46+
let pos = INPUT_CHARSET.find(ch).ok_or_else(|| {
47+
Error::BadDescriptor(format!("Invalid character in checksum: '{}'", ch))
48+
})? as u64;
5049
c = poly_mod(c, pos & 31);
5150
cls = cls * 3 + (pos >> 5);
5251
clscount += 1;

0 commit comments

Comments
 (0)