Skip to content

Commit 367893a

Browse files
committed
Use abs_diff as suggested by clippy
error: manual absolute difference pattern without using `abs_diff` --> x11rb/src/xcb_ffi/mod.rs:692:9 | 692 | / if value > recent { 693 | | value - recent 694 | | } else { 695 | | recent - value 696 | | } | |_________^ help: replace with `abs_diff`: `value.abs_diff(recent)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_abs_diff Signed-off-by: Uli Schlachter <psychon@znc.in>
1 parent 83a443b commit 367893a

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

x11rb/src/xcb_ffi/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -688,13 +688,7 @@ fn reconstruct_full_sequence_impl(recent: SequenceNumber, value: u32) -> Sequenc
688688
]
689689
.iter()
690690
.copied()
691-
.min_by_key(|&value| {
692-
if value > recent {
693-
value - recent
694-
} else {
695-
recent - value
696-
}
697-
})
691+
.min_by_key(|&value| value.abs_diff(recent))
698692
.unwrap();
699693
// Just because: Check that the result matches the passed-in value in the low bits
700694
assert_eq!(

0 commit comments

Comments
 (0)