add helper methods on ValTree
This commit is contained in:
parent
2bc59c7ae2
commit
eaf8cdaa0b
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user