quickjs-rs
quickjs-rs copied to clipboard
Consider using `scopeguard` crate
Recently I've discovered scopeguard
crate. It allows to do RAII-style cleanup of resources similarly to what DroppableValue
structure does, but also provides a nice defer!
macro to do it in a slightly less verbose way, similar to defer
keyword in Go.
@theduke what do you think about replacing DroppableValue
to usage of defer!
macro from scopeguard
crate?
I'd rather rather remove DroppableValue
and extend the types like OwnedValue
(/Ref) (https://github.com/theduke/quickjs-rs/blob/master/src/bindings.rs#L475).
I actually wanted to wrap all types coming out of quickjs immediately with custom types. I didn't do it yet because I wrote them requiring a reference to bindings::Context
and it would have needed some refactoring to instead just hold a raw reference to _sys::Context
in order to be constructable from within callbacks.
@theduke something like this? https://github.com/HiRoFa/quickjs_es_runtime/blob/master/src/quickjs_utils/properties.rs