Struct stable_mir::ty::Const
source · pub struct Const {
pub(crate) kind: ConstantKind,
pub(crate) ty: Ty,
pub id: ConstId,
}
Expand description
Represents a constant in MIR or from the Type system.
Fields§
§kind: ConstantKind
The constant kind.
ty: Ty
The constant type.
id: ConstId
Used for internal tracking of the internal constant.
Implementations§
source§impl Const
impl Const
sourcepub fn new(kind: ConstantKind, ty: Ty, id: ConstId) -> Const
pub fn new(kind: ConstantKind, ty: Ty, id: ConstId) -> Const
Build a constant. Note that this should only be used by the compiler.
sourcepub fn kind(&self) -> &ConstantKind
pub fn kind(&self) -> &ConstantKind
Retrieve the constant kind.
sourcefn try_from_target_usize(val: u64) -> Result<Self, Error>
fn try_from_target_usize(val: u64) -> Result<Self, Error>
Creates an interned usize constant.
sourcepub fn eval_target_usize(&self) -> Result<u64, Error>
pub fn eval_target_usize(&self) -> Result<u64, Error>
Try to evaluate to a target usize
.
sourcepub fn try_new_zero_sized(ty: Ty) -> Result<Const, Error>
pub fn try_new_zero_sized(ty: Ty) -> Result<Const, Error>
Create a constant that represents a new zero-sized constant of type T. Fails if the type is not a ZST or if it doesn’t have a known size.
sourcepub fn from_str(value: &str) -> Const
pub fn from_str(value: &str) -> Const
Build a new constant that represents the given string.
Note that there is no guarantee today about duplication of the same constant. I.e.: Calling this function multiple times with the same argument may or may not return the same allocation.
Trait Implementations§
source§impl PartialEq for Const
impl PartialEq for Const
source§impl Visitable for Const
impl Visitable for Const
fn visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break>
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break>
impl Eq for Const
impl StructuralPartialEq for Const
Auto Trait Implementations§
impl Freeze for Const
impl RefUnwindSafe for Const
impl Send for Const
impl Sync for Const
impl Unpin for Const
impl UnwindSafe for Const
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
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 80 bytes