diff --git a/the_rewrite/src/func.rs b/the_rewrite/src/func.rs index 9365168..c0dcdb9 100644 --- a/the_rewrite/src/func.rs +++ b/the_rewrite/src/func.rs @@ -49,6 +49,10 @@ impl<'a> FTable<'a> { pub fn remove(&self, id: String) { self.0.remove(&id); } + + pub fn new() -> FTable<'a> { + FTable{0: HashMap::>::new()} + } } diff --git a/the_rewrite/src/vars.rs b/the_rewrite/src/vars.rs index 9d02ae9..872fe4f 100644 --- a/the_rewrite/src/vars.rs +++ b/the_rewrite/src/vars.rs @@ -35,12 +35,19 @@ impl<'a> VTable<'a> { } pub fn get(&'a self, id: String) -> Option>> { - self.0.get(&id) + match self.0.get(&id) { + Some(s) => Some(s.clone()), + None => None, + } } pub fn remove(&self, id: String) { self.0.remove(&id); } + + pub fn new() -> VTable<'a> { + VTable{0: HashMap::>::new()} + } } // returns a callback for the stdlib var export function with env_sync on or off