pub enum Operand {
LocalOperand {
name: Name,
ty: TypeRef,
},
ConstantOperand(ConstantRef),
MetadataOperand,
}
Variants
LocalOperand
e.g., i32 %foo
ConstantOperand(ConstantRef)
includes GlobalReference
for things like @foo
MetadataOperand
Implementations
sourceimpl Operand
impl Operand
sourcepub fn as_constant(&self) -> Option<&Constant>
pub fn as_constant(&self) -> Option<&Constant>
Get a reference to the Constant
, if the operand is a constant;
otherwise, returns None
.
This allows nested matching on Operand
. Instead of the following code
(which doesn’t compile because you can’t directly match on ConstantRef
)
ⓘ
if let Operand::ConstantOperand(Constant::Float(Float::Double(val))) = op
you can write this:
ⓘ
if let Some(Constant::Float(Float::Double(val))) = op.as_constant()
Trait Implementations
sourceimpl PartialEq<Operand> for Operand
impl PartialEq<Operand> for Operand
impl StructuralPartialEq for Operand
Auto Trait Implementations
impl RefUnwindSafe for Operand
impl Send for Operand
impl Sync for Operand
impl Unpin for Operand
impl UnwindSafe for Operand
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