diff options
| author | b-naber <bn263@gmx.de> | 2022-04-12 15:07:35 +0200 |
|---|---|---|
| committer | b-naber <bn263@gmx.de> | 2022-04-21 10:59:12 +0200 |
| commit | eaf8cdaa0bcf7bc188da8d8d0a35126cf37b0580 (patch) | |
| tree | 71461a4b81cd7d7076702efafd81e954e6f093fa | |
| parent | 2bc59c7ae2631863e947ccdba42b989feeec6b36 (diff) | |
| download | rust-eaf8cdaa0bcf7bc188da8d8d0a35126cf37b0580.tar.gz rust-eaf8cdaa0bcf7bc188da8d8d0a35126cf37b0580.zip | |
add helper methods on ValTree
| -rw-r--r-- | compiler/rustc_middle/src/ty/consts/valtree.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/consts/valtree.rs b/compiler/rustc_middle/src/ty/consts/valtree.rs index 195760c0590..e17c69cb353 100644 --- a/compiler/rustc_middle/src/ty/consts/valtree.rs +++ b/compiler/rustc_middle/src/ty/consts/valtree.rs @@ -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), + } + } } |
