add Type::add_all()

This commit is contained in:
Mark 2024-03-03 12:55:55 +01:00
parent cb370f59c5
commit 86b6a46d09
2 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "mers_lib"
version = "0.6.0"
version = "0.6.1"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "library to use the mers language in other projects"

View File

@ -298,15 +298,18 @@ impl Type {
pub fn add(&mut self, new: Arc<dyn MersType>) {
let n = new.as_any();
if let Some(s) = n.downcast_ref::<Self>() {
for t in &s.types {
self.add(Arc::clone(t));
}
self.add_all(s);
} else {
if !self.types.iter().any(|t| new.is_included_in(t.as_ref())) {
self.types.push(new);
}
}
}
pub fn add_all(&mut self, types: &Self) {
for t in &types.types {
self.add(Arc::clone(t));
}
}
pub fn dereference(&self) -> Option<Self> {
let mut o = Self::empty();
for t in &self.types {