Add getter to table and other misc changes

This commit is contained in:
Mark McCaskey
2020-03-18 15:29:29 -07:00
parent f864765298
commit 71be2c6763
5 changed files with 70 additions and 6 deletions

View File

@ -89,6 +89,16 @@ impl Table {
self.desc
}
/// Get the `Element` at the given index in the table
pub fn get(&self, index: u32) -> Option<Element> {
let storage = self.storage.lock().unwrap();
match &*storage {
(TableStorage::Anyfunc(ref anyfunc_table), _) => {
anyfunc_table.get(index).map(Element::Anyfunc)
}
}
}
/// Set the element at index.
pub fn set(&self, index: u32, element: Element) -> Result<(), ()> {
let mut storage = self.storage.lock().unwrap();