pub struct Constant {
pub ty: Type,
pub value: ConstantValue,
}
Expand description
A Type
and constant value, including ConstantValue::Undef
for uninitialized constants.
Fields
ty: Type
value: ConstantValue
Implementations
sourceimpl Constant
impl Constant
pub fn new_undef(context: &Context, ty: Type) -> Self
pub fn new_unit() -> Self
pub fn new_bool(b: bool) -> Self
pub fn new_uint(nbits: u8, n: u64) -> Self
pub fn new_b256(bytes: [u8; 32]) -> Self
pub fn new_string(string: String) -> Self
pub fn new_array(aggregate: &Aggregate, elems: Vec<Constant>) -> Self
pub fn new_struct(aggregate: &Aggregate, fields: Vec<Constant>) -> Self
pub fn get_undef(context: &mut Context, ty: Type) -> Value
pub fn get_unit(context: &mut Context) -> Value
pub fn get_bool(context: &mut Context, value: bool) -> Value
pub fn get_uint(context: &mut Context, nbits: u8, value: u64) -> Value
pub fn get_b256(context: &mut Context, value: [u8; 32]) -> Value
pub fn get_string(context: &mut Context, value: String) -> Value
sourcepub fn get_array(context: &mut Context, value: Constant) -> Value
pub fn get_array(context: &mut Context, value: Constant) -> Value
value
must be created as an array constant first, using Constant::new_array()
.
sourcepub fn get_struct(context: &mut Context, value: Constant) -> Value
pub fn get_struct(context: &mut Context, value: Constant) -> Value
value
must be created as a struct constant first, using Constant::new_struct()
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Constant
impl Send for Constant
impl Sync for Constant
impl Unpin for Constant
impl UnwindSafe for Constant
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more