mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-15 20:45:45 +03:00
add helper methods on ValTree
This commit is contained in:
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user