1
Fork 0

Add Place getter to Operand

This commit is contained in:
Dylan MacKenzie 2020-01-24 15:30:51 -08:00
parent 2ed25f0697
commit a64cd59224

View file

@ -1993,6 +1993,15 @@ impl<'tcx> Operand<'tcx> {
Operand::Move(place) => Operand::Copy(place),
}
}
/// Returns the `Place` that is the target of this `Operand`, or `None` if this `Operand` is a
/// constant.
pub fn place(&self) -> Option<&Place<'tcx>> {
match self {
Operand::Copy(place) | Operand::Move(place) => Some(place),
Operand::Constant(_) => None,
}
}
}
///////////////////////////////////////////////////////////////////////////