Add helper for getting an int
out of a Scalar
This commit is contained in:
parent
f03b18b99b
commit
500af76831
2 changed files with 9 additions and 4 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue