mirror of
https://github.com/Dummi26/mers.git
synced 2025-03-10 14:13:52 +01:00
add Type::add_all()
This commit is contained in:
parent
cb370f59c5
commit
86b6a46d09
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "mers_lib"
|
name = "mers_lib"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "library to use the mers language in other projects"
|
description = "library to use the mers language in other projects"
|
||||||
|
@ -298,15 +298,18 @@ impl Type {
|
|||||||
pub fn add(&mut self, new: Arc<dyn MersType>) {
|
pub fn add(&mut self, new: Arc<dyn MersType>) {
|
||||||
let n = new.as_any();
|
let n = new.as_any();
|
||||||
if let Some(s) = n.downcast_ref::<Self>() {
|
if let Some(s) = n.downcast_ref::<Self>() {
|
||||||
for t in &s.types {
|
self.add_all(s);
|
||||||
self.add(Arc::clone(t));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if !self.types.iter().any(|t| new.is_included_in(t.as_ref())) {
|
if !self.types.iter().any(|t| new.is_included_in(t.as_ref())) {
|
||||||
self.types.push(new);
|
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> {
|
pub fn dereference(&self) -> Option<Self> {
|
||||||
let mut o = Self::empty();
|
let mut o = Self::empty();
|
||||||
for t in &self.types {
|
for t in &self.types {
|
||||||
|
Loading…
Reference in New Issue
Block a user