1 2 3 4 5 6 7 8 9 10 11 12 13 14
use var::Var; use def::Def; pub struct Fun(Box<FnMut(&[Var], &Def) -> Option<Var> + Send>); impl Fun { pub fn run(&mut self, args: &[Var], def: &Def) -> Option<Var> { self.0(args, def) } pub fn new<F: 'static + Send>(fun: F) -> Fun where F: FnMut(&[Var], &Def) -> Option<Var> { Fun(Box::new(fun)) } }