add helper methods on ValTree

This commit is contained in:
b-naber 2022-04-12 15:07:35 +02:00
parent 2bc59c7ae2
commit eaf8cdaa0b

View File

@ -31,4 +31,20 @@ impl<'tcx> ValTree<'tcx> {
pub fn zst() -> Self {
Self::Branch(&[])
}
#[inline]
pub fn unwrap_leaf(self) -> ScalarInt {
match self {
Self::Leaf(s) => s,
_ => bug!("expected leaf, got {:?}", self),
}
}
#[inline]
pub fn unwrap_branch(self) -> &'tcx [Self] {
match self {
Self::Branch(branch) => branch,
_ => bug!("expected branch, got {:?}", self),
}
}
}