Skip to content

Commit 4b9857e

Browse files
committed
Created IFn protocol
1 parent 37c71b9 commit 4b9857e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/protocols/ifn.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::value::{Value,ToValue};
2+
use std::rc::Rc;
3+
use crate::ifn;
4+
5+
// Let's keep it simple for now, but we will expand this
6+
define_protocol!(IFn,IFn);
7+
8+
impl ifn::IFn for IFn {
9+
fn invoke(&self, args: Vec<Rc<Value>>) -> Value {
10+
match &*self.value {
11+
Value::IFn(ifn) => {
12+
ifn.invoke(args)
13+
},
14+
_ => panic!("Called Iterable iter on non-iterable"),
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)