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,
span_md_idx: Option<MetadataIndex>
) -> Value
pub fn get_unit(
context: &mut Context,
span_md_idx: Option<MetadataIndex>
) -> Value
pub fn get_bool(
context: &mut Context,
value: bool,
span_md_idx: Option<MetadataIndex>
) -> Value
pub fn get_uint(
context: &mut Context,
nbits: u8,
value: u64,
span_md_idx: Option<MetadataIndex>
) -> Value
pub fn get_b256(
context: &mut Context,
value: [u8; 32],
span_md_idx: Option<MetadataIndex>
) -> Value
pub fn get_string(
context: &mut Context,
value: String,
span_md_idx: Option<MetadataIndex>
) -> Value
sourcepub fn get_array(
context: &mut Context,
value: Constant,
span_md_idx: Option<MetadataIndex>
) -> Value
pub fn get_array(
context: &mut Context,
value: Constant,
span_md_idx: Option<MetadataIndex>
) -> Value
value
must be created as an array constant first, using Constant::new_array()
.
sourcepub fn get_struct(
context: &mut Context,
value: Constant,
span_md_idx: Option<MetadataIndex>
) -> Value
pub fn get_struct(
context: &mut Context,
value: Constant,
span_md_idx: Option<MetadataIndex>
) -> 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
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.
sourcefn clone_into(&self, target: &mut T)
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