From b6a242e28fe6c795757d54a208124c8021e23f3d Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 14 Mar 2023 21:22:08 +0100 Subject: [PATCH] Simplify type conversion. --- bindgen/clang.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bindgen/clang.rs b/bindgen/clang.rs index 8f49a0f8ca..13cb94a15f 100644 --- a/bindgen/clang.rs +++ b/bindgen/clang.rs @@ -2125,11 +2125,7 @@ impl EvalResult { if unsafe { clang_EvalResult_isUnsignedInt(self.x) } != 0 { let value = unsafe { clang_EvalResult_getAsUnsigned(self.x) }; - if value as u128 > i128::MAX as u128 { - return None; - } - - return Some(value as i128); + return i128::try_from(value).ok() } let value = unsafe { clang_EvalResult_getAsLongLong(self.x) };