1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
use std::{ rc::Rc, cell::RefCell, }; use crate::common::{ stamp::stamp, lambda::Lambda, data::Data, }; /// Wraps a `Lambda` with some scope context. /// > NOTE: currently a work-in-progress. #[derive(Debug, Clone, PartialEq)] pub struct Closure { pub id: String, pub lambda: Lambda, pub captures: Vec<Rc<RefCell<Data>>>, } impl Closure { /// Constructs a new `Closure` by wrapping a `Lambda`. pub fn wrap(lambda: Lambda) -> Closure { Closure { id: stamp(0), lambda, captures: vec![] } } }