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: Vec<u8>) -> 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: Vec<u8>) -> 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 · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more