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

Removing IsValid #19

Open
dzfranklin opened this issue May 9, 2021 · 2 comments
Open

Removing IsValid #19

dzfranklin opened this issue May 9, 2021 · 2 comments

Comments

@dzfranklin
Copy link
Contributor

dzfranklin commented May 9, 2021

Hi, first off I want to thank you for this library. It's made my life so much easier.

There are definitely ways to cause UB in safe Rust with this library. The main one I ran into today was needing to call is_valid before calling any other methods on some types.

I think it would be more "rust-y" if maybe_wrap was the default and wrap was unsafe and only used when the check is too expensive for performance reasons and we already knew it was valid for another reason. This would mean if I had a SBFoo I'd know it's already been checked for validity.

I'm not up for making this change to everything at once but I'm open to doing this for some types as I work on my own project, if that sounds useful to you?

@waywardmonkeys
Copy link
Contributor

I agree that this needs improving!

There are a lot of places where we should be returning an Option for sure.

@waywardmonkeys
Copy link
Contributor

I like the IsValid trait in the lldb bindings from the vscode extension.

Having that have a .check() is nice ... and if I had an impl of Into / From that let you do:

let raw = unsafe { CreateSBWhatever() };
raw.into().check()

That'd be nicer than what is done now with wrap / maybe_wrap.

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