Merge pull request #3050 from rtfeldman/bindgen-tag-payloads

Bindgen single-tag unions
This commit is contained in:
Richard Feldman 2022-05-10 19:27:25 -04:00 committed by GitHub
commit 11e2faa87a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 214 additions and 78 deletions

View file

@ -2396,6 +2396,17 @@ impl UnionTags {
.zip(self.variables().into_iter())
}
/// Iterator over (TagName, &[Variable]) pairs obtained by
/// looking up slices in the given Subs
pub fn iter_from_subs<'a>(
&'a self,
subs: &'a Subs,
) -> impl Iterator<Item = (&'a TagName, &'a [Variable])> + ExactSizeIterator {
self.iter_all().map(move |(name_index, payload_index)| {
(&subs[name_index], subs.get_subs_slice(subs[payload_index]))
})
}
#[inline(always)]
pub fn unsorted_iterator<'a>(
&'a self,