Skip to content

Commit 7224bfa

Browse files
committed
test(utils): replace if-let with ? operator
1 parent 8fb4ebd commit 7224bfa

File tree

1 file changed

+8
-11
lines changed
  • src/r3_core/src/utils/binary_heap

1 file changed

+8
-11
lines changed

src/r3_core/src/utils/binary_heap/tests.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@ fn interpret(bytecode: &[u8], max_len: usize) -> impl Iterator<Item = Cmd> + '_
1616
let mut i = 0;
1717
let mut len = 0;
1818
std::iter::from_fn(move || {
19-
if let Some(instr) = bytecode.get(i..i + 5) {
20-
i += 5;
19+
let instr = bytecode.get(i..i + 5)?;
20+
i += 5;
2121

22-
let value = u32::from_le_bytes([instr[1], instr[2], instr[3], instr[4]]) as usize;
22+
let value = u32::from_le_bytes([instr[1], instr[2], instr[3], instr[4]]) as usize;
2323

24-
if (instr[0] % 2 == 0 && len != max_len) || len == 0 {
25-
len += 1;
26-
Some(Cmd::Insert(value))
27-
} else {
28-
len -= 1;
29-
Some(Cmd::Remove(value % (len + 1)))
30-
}
24+
if (instr[0] % 2 == 0 && len != max_len) || len == 0 {
25+
len += 1;
26+
Some(Cmd::Insert(value))
3127
} else {
32-
None
28+
len -= 1;
29+
Some(Cmd::Remove(value % (len + 1)))
3330
}
3431
})
3532
}

0 commit comments

Comments
 (0)