Consume context on destroy

This commit is contained in:
Rafael Caricio 2020-01-04 13:44:55 +01:00
parent b2671b10bd
commit dfe5157e87
3 changed files with 3 additions and 3 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
/target
**/*.rs.bk
Cargo.lock
.idea

View file

@ -10,4 +10,4 @@ license = "Unlicense"
description = "Safe(er) rust wrapper for dukbind."
[dependencies]
dukbind = "0.0.4"
dukbind = { path = "../dukbind" }

View file

@ -370,10 +370,9 @@ impl DukContext {
}
}
/// Destroy the duktape context's heap. Should not be used after calling this.
pub fn destroy(&mut self) {
pub fn destroy(self) {
unsafe {
duk_destroy_heap(self.ctx.expect("Invalid context pointer."));
self.ctx = None;
}
}
/// Decode a JSON string into the context, returning a DukObject.