Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using scopeguard crate #41

Open
ghost opened this issue Sep 21, 2019 · 2 comments
Open

Consider using scopeguard crate #41

ghost opened this issue Sep 21, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Sep 21, 2019

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?

@theduke
Copy link
Owner

theduke commented Sep 21, 2019

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.

@andrieshiemstra
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants