mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
Merge pull request #3050 from rtfeldman/bindgen-tag-payloads
Bindgen single-tag unions
This commit is contained in:
commit
11e2faa87a
6 changed files with 214 additions and 78 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue