pub enum ConstantScalarValue {
Int(i64, IntKind),
Float(f64, FloatKind),
UInt(u64, UIntKind),
Bool(bool),
}
Expand description
The scalars are stored with the highest precision possible, but they might get reduced during compilation.
Variants§
Implementations§
Source§impl ConstantScalarValue
impl ConstantScalarValue
Sourcepub fn try_as_usize(&self) -> Option<usize>
pub fn try_as_usize(&self) -> Option<usize>
Returns the value of the scalar as a usize.
It will return None if the scalar type is a float or a bool.
Sourcepub fn as_usize(&self) -> usize
pub fn as_usize(&self) -> usize
Returns the value of the scalar as a usize.
It will panic if the scalar type is a float or a bool.
Sourcepub fn try_as_u32(&self) -> Option<u32>
pub fn try_as_u32(&self) -> Option<u32>
Returns the value of the scalar as a u32.
It will return None if the scalar type is a float or a bool.
Sourcepub fn as_u32(&self) -> u32
pub fn as_u32(&self) -> u32
Returns the value of the scalar as a u32.
It will panic if the scalar type is a float or a bool.
Sourcepub fn try_as_u64(&self) -> Option<u64>
pub fn try_as_u64(&self) -> Option<u64>
Returns the value of the scalar as a u64.
It will return None if the scalar type is a float or a bool.
Sourcepub fn as_u64(&self) -> u64
pub fn as_u64(&self) -> u64
Returns the value of the scalar as a u64.
It will panic if the scalar type is a float or a bool.
Sourcepub fn try_as_i64(&self) -> Option<i64>
pub fn try_as_i64(&self) -> Option<i64>
Returns the value of the scalar as a i64.
It will return None if the scalar type is a float or a bool.
Sourcepub fn as_i64(&self) -> i64
pub fn as_i64(&self) -> i64
Returns the value of the scalar as a u32.
It will panic if the scalar type is a float or a bool.
Sourcepub fn try_as_bool(&self) -> Option<bool>
pub fn try_as_bool(&self) -> Option<bool>
Returns the value of the variable as a bool if it actually is a bool.
Sourcepub fn as_bool(&self) -> bool
pub fn as_bool(&self) -> bool
Returns the value of the variable as a bool.
It will panic if the scalar isn’t a bool.
pub fn is_zero(&self) -> bool
pub fn is_one(&self) -> bool
pub fn cast_to(&self, other: Elem) -> ConstantScalarValue
Trait Implementations§
Source§impl Clone for ConstantScalarValue
impl Clone for ConstantScalarValue
Source§fn clone(&self) -> ConstantScalarValue
fn clone(&self) -> ConstantScalarValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more