mirror of
https://github.com/Dummi26/mers.git
synced 2026-03-04 08:36:33 +01:00
fix todo!()s in with_iters
This commit is contained in:
@@ -36,6 +36,16 @@ impl Function {
|
||||
pub fn run(&self, arg: Data) -> Data {
|
||||
(self.run)(arg, &mut self.info.as_ref().clone())
|
||||
}
|
||||
pub fn get_as_type(&self) -> FunctionT {
|
||||
let out = Arc::clone(&self.out);
|
||||
let info = Arc::clone(&self.info_check);
|
||||
FunctionT(Arc::new(move |a| {
|
||||
let lock = info.lock().unwrap();
|
||||
let mut info = lock.clone();
|
||||
drop(lock);
|
||||
out(a, &mut info)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
impl MersData for Function {
|
||||
@@ -52,14 +62,7 @@ impl MersData for Function {
|
||||
Box::new(Clone::clone(self))
|
||||
}
|
||||
fn as_type(&self) -> Type {
|
||||
let out = Arc::clone(&self.out);
|
||||
let info = Arc::clone(&self.info_check);
|
||||
Type::new(FunctionT(Arc::new(move |a| {
|
||||
let lock = info.lock().unwrap();
|
||||
let mut info = lock.clone();
|
||||
drop(lock);
|
||||
out(a, &mut info)
|
||||
})))
|
||||
Type::new(self.get_as_type())
|
||||
}
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
|
||||
@@ -265,6 +265,27 @@ impl Type {
|
||||
}
|
||||
Some(o)
|
||||
}
|
||||
/// Returns `Some(d)` if self is `()/(d)`
|
||||
pub fn one_tuple_possible_content(&self) -> Option<Type> {
|
||||
let mut o = Self::empty();
|
||||
let mut nothing = true;
|
||||
for t in &self.types {
|
||||
if let Some(t) = t
|
||||
.as_any()
|
||||
.downcast_ref::<crate::data::tuple::TupleT>()
|
||||
.filter(|v| v.0.len() == 1)
|
||||
.and_then(|v| v.0.get(0))
|
||||
{
|
||||
nothing = false;
|
||||
o.add(Arc::new(t.clone()));
|
||||
}
|
||||
}
|
||||
if nothing {
|
||||
None
|
||||
} else {
|
||||
Some(o)
|
||||
}
|
||||
}
|
||||
pub fn add(&mut self, new: Arc<dyn MersType>) {
|
||||
let n = new.as_any();
|
||||
if let Some(s) = n.downcast_ref::<Self>() {
|
||||
|
||||
Reference in New Issue
Block a user