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§
source§impl 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§
source§impl PartialEq for Operand
impl PartialEq 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§
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
Mutably borrows from an owned value. Read more