new implementations and one less lifetime bug

Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
Ava Hahn 2023-02-01 19:59:46 -08:00
parent 0a14ea7182
commit e6bb732f18
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
2 changed files with 12 additions and 1 deletions

View file

@ -49,6 +49,10 @@ impl<'a> FTable<'a> {
pub fn remove(&self, id: String) { pub fn remove(&self, id: String) {
self.0.remove(&id); self.0.remove(&id);
} }
pub fn new() -> FTable<'a> {
FTable{0: HashMap::<String, Box<Function>>::new()}
}
} }

View file

@ -35,12 +35,19 @@ impl<'a> VTable<'a> {
} }
pub fn get(&'a self, id: String) -> Option<Box<Ctr<'a>>> { pub fn get(&'a self, id: String) -> Option<Box<Ctr<'a>>> {
self.0.get(&id) match self.0.get(&id) {
Some(s) => Some(s.clone()),
None => None,
}
} }
pub fn remove(&self, id: String) { pub fn remove(&self, id: String) {
self.0.remove(&id); self.0.remove(&id);
} }
pub fn new() -> VTable<'a> {
VTable{0: HashMap::<String, Box<Ctr>>::new()}
}
} }
// returns a callback for the stdlib var export function with env_sync on or off // returns a callback for the stdlib var export function with env_sync on or off