Skip to content

Commit c8edd9a

Browse files
author
Michael Wright
committed
Remove casts from FullInt impl
1 parent 665ff57 commit c8edd9a

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

clippy_utils/src/consts.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,9 @@ pub enum FullInt {
230230
}
231231

232232
impl FullInt {
233-
#[allow(clippy::cast_sign_loss)]
234233
#[must_use]
235234
fn cmp_s_u(s: i128, u: u128) -> Ordering {
236-
if s < 0 {
237-
Ordering::Less
238-
} else if u > (i128::MAX as u128) {
239-
Ordering::Greater
240-
} else {
241-
(s as u128).cmp(&u)
242-
}
235+
u128::try_from(s).map_or(Ordering::Less, |x| x.cmp(&u))
243236
}
244237
}
245238

0 commit comments

Comments
 (0)