fn tokenize_int(value: &str) -> Result<[u8; 32], Error> {
		let result = StrictTokenizer::tokenize_int(value);
		if result.is_ok() {
			return result;
		}

		let abs = Uint::from_dec_str(value.trim_start_matches('-'))?;
		let max = Uint::max_value() / 2;
		let int = if value.starts_with('-') {
			if abs.is_zero() {
				return Ok(abs.into());
			} else if abs > max + 1 {
				return Err(Error::Other(Cow::Borrowed("int256 parse error: Underflow")));
			}
			!abs + 1 // two's complement
		} else {
			if abs > max {
				return Err(Error::Other(Cow::Borrowed("int256 parse error: Overflow")));
			}
			abs
		};
		Ok(int.into())
	}
// We don't have a proper signed int 256-bit long type, so here we're cheating. We build a U256
// out of it and check that it's within the lower/upper bound of a hypothetical I256 type: half
// the `U256::max_value().
We don't have a proper signed int 256-bit long type, so here we're cheating. We build a U256
out of it and check that it's within the lower/upper bound of a hypothetical I256 type: half
the `U256::max_value().
We don ' t have a proper signed int 256 - bit long type so here we ' re cheating . We build a U256 out of it and check that it ' s within the lower / upper bound of a hypothetical I256 type : half the ` U256 :: max_value () .
fn tokenize_int(value: &str) -> Result<[u8; 32], Error> {
		let result = StrictTokenizer::tokenize_int(value);
		if result.is_ok() {
			return result;
		}
		let abs = Uint::from_dec_str(value.trim_start_matches('-'))?;
		let max = Uint::max_value() / 2;
		let int = if value.starts_with('-') {
			if abs.is_zero() {
				return Ok(abs.into());
			} else if abs > max + 1 {
				return Err(Error::Other(Cow::Borrowed("int256 parse error: Underflow")));
			}
			!abs + 1 // two's complement
		} else {
			if abs > max {
				return Err(Error::Other(Cow::Borrowed("int256 parse error: Overflow")));
			}
			abs
		};
		Ok(int.into())
	}
fn tokenize_int ( value : & str ) -> Result < [ u8 ; 32 ] , Error > { let result = StrictTokenizer :: tokenize_int ( value ) ; if result . is_ok ( ) { return result ; } let abs = Uint :: from_dec_str ( value . trim_start_matches ( '-' ) ) ? ; let max = Uint :: max_value ( ) / 2 ; let int = if value . starts_with ( '-' ) { if abs . is_zero ( ) { return Ok ( abs . into ( ) ) ; } else if abs > max + 1 { return Err ( Error :: Other ( Cow :: Borrowed ( " " ) ) ) ; } ! abs + 1 // two's complement } else { if abs > max { return Err ( Error :: Other ( Cow :: Borrowed ( " " ) ) ) ; } abs } ; Ok ( int . into ( ) ) }
We don't have a proper signed int 256-bit long type, so here we're cheating.
We don ' t have a proper signed int 256 - bit long type so here we ' re cheating .
value
&str