add helper methods on ValTree
This commit is contained in:
parent
2bc59c7ae2
commit
eaf8cdaa0b
1 changed files with 16 additions and 0 deletions
|
@ -31,4 +31,20 @@ impl<'tcx> ValTree<'tcx> {
|
||||||
pub fn zst() -> Self {
|
pub fn zst() -> Self {
|
||||||
Self::Branch(&[])
|
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…
Add table
Add a link
Reference in a new issue