formatting for Defs

This commit is contained in:
Folkert 2022-05-25 14:58:36 +02:00
parent 2ae804790a
commit d72ebf4b74
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
7 changed files with 57 additions and 25 deletions

View file

@ -345,6 +345,15 @@ pub struct Defs<'a> {
pub value_defs: std::vec::Vec<ValueDef<'a>>,
}
impl<'a> Defs<'a> {
pub fn defs(&self) -> impl Iterator<Item = Result<&TypeDef<'a>, &ValueDef<'a>>> {
self.tags.iter().map(|tag| match tag.split() {
Ok(type_index) => Ok(&self.type_defs[type_index.index()]),
Err(value_index) => Err(&self.value_defs[value_index.index()]),
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Def<'a> {
Type(TypeDef<'a>),