1
Fork 0

Add helper for getting an int out of a Scalar

This commit is contained in:
oli 2020-11-01 17:21:33 +00:00
parent f03b18b99b
commit 500af76831
2 changed files with 9 additions and 4 deletions

View file

@ -357,6 +357,14 @@ impl<'tcx, Tag> Scalar<Tag> {
self.to_bits(target_size).expect("expected Raw bits but got a Pointer")
}
#[inline]
pub fn assert_int(self) -> ScalarInt {
match self {
Scalar::Ptr(_) => bug!("expected an int but got an abstract pointer"),
Scalar::Int(int) => int,
}
}
#[inline]
pub fn assert_ptr(self) -> Pointer<Tag> {
match self {