pub enum ScalarValue {
Isize(i64),
I8(i8),
I16(i16),
I32(i32),
I64(i64),
I128(i128),
Usize(u64),
U8(u8),
U16(u16),
U32(u32),
U64(u64),
U128(u128),
}
Expand description
A scalar value.
Variants§
Isize(i64)
Using i64 to be safe
I8(i8)
I16(i16)
I32(i32)
I64(i64)
I128(i128)
Usize(u64)
Using u64 to be safe
U8(u8)
U16(u16)
U32(u32)
U64(u64)
U128(u128)
Implementations§
source§impl ScalarValue
impl ScalarValue
pub fn is_isize(&self) -> bool
pub fn is_i8(&self) -> bool
pub fn is_i16(&self) -> bool
pub fn is_i32(&self) -> bool
pub fn is_i64(&self) -> bool
pub fn is_i128(&self) -> bool
pub fn is_usize(&self) -> bool
pub fn is_u8(&self) -> bool
pub fn is_u16(&self) -> bool
pub fn is_u32(&self) -> bool
pub fn is_u64(&self) -> bool
pub fn is_u128(&self) -> bool
source§impl ScalarValue
impl ScalarValue
pub fn as_isize(&self) -> Option<&i64>
pub fn as_i8(&self) -> Option<&i8>
pub fn as_i16(&self) -> Option<&i16>
pub fn as_i32(&self) -> Option<&i32>
pub fn as_i64(&self) -> Option<&i64>
pub fn as_i128(&self) -> Option<&i128>
pub fn as_usize(&self) -> Option<&u64>
pub fn as_u8(&self) -> Option<&u8>
pub fn as_u16(&self) -> Option<&u16>
pub fn as_u32(&self) -> Option<&u32>
pub fn as_u64(&self) -> Option<&u64>
pub fn as_u128(&self) -> Option<&u128>
source§impl ScalarValue
impl ScalarValue
pub fn as_isize_mut(&mut self) -> Option<&mut i64>
pub fn as_i8_mut(&mut self) -> Option<&mut i8>
pub fn as_i16_mut(&mut self) -> Option<&mut i16>
pub fn as_i32_mut(&mut self) -> Option<&mut i32>
pub fn as_i64_mut(&mut self) -> Option<&mut i64>
pub fn as_i128_mut(&mut self) -> Option<&mut i128>
pub fn as_usize_mut(&mut self) -> Option<&mut u64>
pub fn as_u8_mut(&mut self) -> Option<&mut u8>
pub fn as_u16_mut(&mut self) -> Option<&mut u16>
pub fn as_u32_mut(&mut self) -> Option<&mut u32>
pub fn as_u64_mut(&mut self) -> Option<&mut u64>
pub fn as_u128_mut(&mut self) -> Option<&mut u128>
source§impl ScalarValue
impl ScalarValue
pub fn variant_name(&self) -> &'static str
source§impl ScalarValue
impl ScalarValue
pub fn variant_index_arity(&self) -> (u32, usize)
source§impl ScalarValue
impl ScalarValue
pub fn get_integer_ty(&self) -> IntegerTy
pub fn is_int(&self) -> bool
pub fn is_uint(&self) -> bool
sourcepub fn as_uint(&self) -> ScalarResult<u128>
pub fn as_uint(&self) -> ScalarResult<u128>
When computing the result of binary operations, we convert the values to u128 then back to the target type (while performing dynamic checks of course).
pub fn uint_is_in_bounds(ty: IntegerTy, v: u128) -> bool
pub fn from_unchecked_uint(ty: IntegerTy, v: u128) -> ScalarValue
pub fn from_uint(ty: IntegerTy, v: u128) -> ScalarResult<ScalarValue>
sourcepub fn as_int(&self) -> ScalarResult<i128>
pub fn as_int(&self) -> ScalarResult<i128>
When computing the result of binary operations, we convert the values to i128 then back to the target type (while performing dynamic checks of course).
pub fn int_is_in_bounds(ty: IntegerTy, v: i128) -> bool
pub fn from_unchecked_int(ty: IntegerTy, v: i128) -> ScalarValue
pub fn from_le_bytes(ty: IntegerTy, b: [u8; 16]) -> ScalarValue
sourcepub fn to_bits(&self) -> u128
pub fn to_bits(&self) -> u128
Most integers are represented as u128
by rustc. We must be careful not to sign-extend.
pub fn from_bits(ty: IntegerTy, bits: u128) -> Self
sourcepub fn from_int(ty: IntegerTy, v: i128) -> ScalarResult<ScalarValue>
pub fn from_int(ty: IntegerTy, v: i128) -> ScalarResult<ScalarValue>
Warning: most constants are stored as u128 by rustc. When converting
to i128, it is not correct to do v as i128
, we must reinterpret the
bits (see ScalarValue::from_le_bytes).
pub fn to_constant(self) -> ConstantExpr
Trait Implementations§
source§impl Clone for ScalarValue
impl Clone for ScalarValue
source§fn clone(&self) -> ScalarValue
fn clone(&self) -> ScalarValue
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ScalarValue
impl Debug for ScalarValue
source§impl<'de> Deserialize<'de> for ScalarValue
impl<'de> Deserialize<'de> for ScalarValue
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for ScalarValue
impl Display for ScalarValue
source§impl Hash for ScalarValue
impl Hash for ScalarValue
source§impl Ord for ScalarValue
impl Ord for ScalarValue
source§fn cmp(&self, other: &ScalarValue) -> Ordering
fn cmp(&self, other: &ScalarValue) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for ScalarValue
impl PartialEq for ScalarValue
source§impl PartialOrd for ScalarValue
impl PartialOrd for ScalarValue
source§impl Serialize for ScalarValue
impl Serialize for ScalarValue
Custom serializer that stores integers as strings to avoid overflow.
impl Copy for ScalarValue
impl Eq for ScalarValue
impl StructuralPartialEq for ScalarValue
Auto Trait Implementations§
impl Freeze for ScalarValue
impl RefUnwindSafe for ScalarValue
impl Send for ScalarValue
impl Sync for ScalarValue
impl Unpin for ScalarValue
impl UnwindSafe for ScalarValue
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Given the context attached to a nom error, and given the original
input to the nom parser, extract more the useful context information. Read more
§impl<T> Indentable for Twhere
T: Display,
impl<T> Indentable for Twhere
T: Display,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Given the original input, as well as the context reported by nom,
recreate a context in the original string where the error occurred. Read more