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

Support for unsafe functions #143

Open
nearest-river opened this issue Jan 1, 2024 · 0 comments
Open

Support for unsafe functions #143

nearest-river opened this issue Jan 1, 2024 · 0 comments

Comments

@nearest-river
Copy link

Supporting unsafe functions for deno_bindgen would be so great as it'll eliminate the need to use an unsafe block when using pointers which is pretty annoying...

Now

#[deno_bindgen]
pub fn some_method(ptr: usize) {
  unsafe {
    let this=(ptr as *const SomeStruct).as_ref().unwrap();
    this.some_method();
  }
}

Better one

#[deno_bindgen]
pub unsafe fn some_method(ptr: usize) {
  let this=(ptr as *const SomeStruct).as_ref().unwrap();
  this.some_method();
}
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

1 participant