diff --git a/src/eval/chaining.rs b/src/eval/chaining.rs index 2812a163..3a776af9 100644 --- a/src/eval/chaining.rs +++ b/src/eval/chaining.rs @@ -859,7 +859,8 @@ impl Engine { ( start as u8, // 2^bits - 1 - (((2 as crate::UINT).pow((end - start) as u32) - 1) as crate::INT) + (((2 as crate::UNSIGNED_INT).pow((end - start) as u32) - 1) + as crate::INT) << start, ) } @@ -883,7 +884,8 @@ impl Engine { ( start as u8, // 2^bits - 1 - (((2 as crate::UINT).pow((end - start + 1) as u32) - 1) as crate::INT) + (((2 as crate::UNSIGNED_INT).pow((end - start + 1) as u32) - 1) + as crate::INT) << start, ) } diff --git a/src/lib.rs b/src/lib.rs index 44cd7d70..df685645 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -112,7 +112,8 @@ pub type INT = i32; /// If the `only_i32` feature is enabled, this will be [`u32`] instead. #[cfg(not(feature = "only_i32"))] #[allow(non_camel_case_types)] -type UINT = u64; +type UNSIGNED_INT = u64; + /// The unsigned system integer base type. /// It is defined as [`u32`] since the `only_i32` feature is used. /// diff --git a/src/packages/bit_field.rs b/src/packages/bit_field.rs index 92f9c6c6..6d6ae617 100644 --- a/src/packages/bit_field.rs +++ b/src/packages/bit_field.rs @@ -2,7 +2,9 @@ use crate::eval::calc_index; use crate::plugin::*; -use crate::{def_package, ExclusiveRange, InclusiveRange, Position, RhaiResultOf, ERR, INT, UINT}; +use crate::{ + def_package, ExclusiveRange, InclusiveRange, Position, RhaiResultOf, ERR, INT, UNSIGNED_INT, +}; #[cfg(feature = "no_std")] use std::prelude::v1::*; @@ -75,7 +77,7 @@ mod bit_field_functions { } // 2^bits - 1 - let mask = ((2 as UINT).pow(bits as u32) - 1) as crate::INT; + let mask = ((2 as UNSIGNED_INT).pow(bits as u32) - 1) as crate::INT; Ok(((value & (mask << bit)) >> bit) & mask) } @@ -121,7 +123,7 @@ mod bit_field_functions { } // 2^bits - 1 - let mask = ((2 as UINT).pow(bits as u32) - 1) as crate::INT; + let mask = ((2 as UNSIGNED_INT).pow(bits as u32) - 1) as crate::INT; *value &= !(mask << bit); *value |= (new_value & mask) << bit; diff --git a/src/packages/math_basic.rs b/src/packages/math_basic.rs index 594ddb6b..83f2efac 100644 --- a/src/packages/math_basic.rs +++ b/src/packages/math_basic.rs @@ -1,7 +1,7 @@ #![allow(non_snake_case)] use crate::plugin::*; -use crate::{def_package, Position, RhaiResultOf, ERR, INT, UINT}; +use crate::{def_package, Position, RhaiResultOf, ERR, INT, UNSIGNED_INT}; #[cfg(feature = "no_std")] use std::prelude::v1::*; @@ -118,7 +118,7 @@ mod int_functions { .into()); } - UINT::from_str_radix(string.trim(), radix as u32) + UNSIGNED_INT::from_str_radix(string.trim(), radix as u32) .map(|v| v as INT) .map_err(|err| { ERR::ErrorArithmetic( diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 2d925d5e..df7508da 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -5,7 +5,7 @@ use crate::engine::{ KEYWORD_FN_PTR_CURRY, KEYWORD_IS_DEF_VAR, KEYWORD_PRINT, KEYWORD_THIS, KEYWORD_TYPE_OF, }; use crate::func::native::OnParseTokenCallback; -use crate::{Engine, LexError, StaticVec, INT, UINT}; +use crate::{Engine, LexError, StaticVec, INT, UNSIGNED_INT}; #[cfg(feature = "no_std")] use std::prelude::v1::*; use std::{ @@ -1530,7 +1530,7 @@ fn get_next_token_inner( .filter(|&&c| c != NUMBER_SEPARATOR) .collect(); - UINT::from_str_radix(&out, radix) + UNSIGNED_INT::from_str_radix(&out, radix) .map(|v| v as INT) .map(Token::IntegerConstant) .unwrap_or_else(|_| {