From cc095a4ba7cc25c4df7d7e0842ad7402491bfd58 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Fri, 23 Oct 2020 17:27:06 +0100 Subject: [PATCH] Remove assert in Uint256::from_i64 and return None instead --- src/util/uint.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/util/uint.rs b/src/util/uint.rs index 5aba6129..376dc7d2 100644 --- a/src/util/uint.rs +++ b/src/util/uint.rs @@ -83,8 +83,11 @@ macro_rules! construct_uint { /// Create an object from a given signed 64-bit integer #[inline] pub fn from_i64(init: i64) -> Option<$name> { - assert!(init >= 0); - $name::from_u64(init as u64) + if init >= 0 { + $name::from_u64(init as u64) + } else { + None + } } /// Creates big integer value from a byte slice array using