Skip to content

Commit

Permalink
Expose the 'remove' method for objects (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobsonchase authored Apr 24, 2022
1 parent a7d84bd commit 26a7843
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/rune/src/modules/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub fn module() -> Result<Module, ContextError> {

module.inst_fn("len", Object::len)?;
module.inst_fn("insert", Object::insert)?;
module.inst_fn("remove", remove)?;
module.inst_fn("clear", Object::clear)?;
module.inst_fn("contains_key", contains_key)?;
module.inst_fn("get", get)?;
Expand All @@ -26,6 +27,10 @@ fn contains_key(object: &Object, key: &str) -> bool {
object.contains_key(key)
}

fn remove(object: &mut Object, key: &str) -> Option<Value> {
object.remove(key)
}

fn get(object: &Object, key: &str) -> Option<Value> {
object.get(key).cloned()
}
Expand Down

0 comments on commit 26a7843

Please sign in to comment.