Skip to content

Add *c_void (*Void) conversion functions #4725

New issue

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

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

Already on GitHub? # to your account

Closed
brson opened this issue Feb 1, 2013 · 6 comments
Closed

Add *c_void (*Void) conversion functions #4725

brson opened this issue Feb 1, 2013 · 6 comments
Labels
P-low Low priority

Comments

@brson
Copy link
Contributor

brson commented Feb 1, 2013

*c_void (or potentially *Void #4724) is my preferred hammer when I need to pass around some untyped pointers. Currently I use transmute to convert back and forth, but I might instead want something like:

impl *Void {
  static unsafe fn from_borrowed<T: Voidable>(&T);
  unsafe fn to_borrowed<T: Voidable>(self) -> &T;
}

etc. Writing Void::from_borrowed makes the code more obvious than transmute, since transmute can mean anything.

@catamorphism
Copy link
Contributor

Nominating for milestone 3, feature-complete

@graydon
Copy link
Contributor

graydon commented May 23, 2013

accepted for feature-complete milestone

@thestinger
Copy link
Contributor

You can now coerce borrowed pointers to raw pointers, and it's possible to make arbitrary casts of raw pointers with as. It's still very error-prone to convert back to a borrowed pointer, but lifetimes make that tricky.

@brson
Copy link
Contributor Author

brson commented Feb 13, 2014

This doesn't particularly matter to me any more, and Void should maybe not exist.

@pnkfelix
Copy link
Member

assigning P-low.

@pnkfelix
Copy link
Member

actually, closing, since brson no longer cares about this.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
P-low Low priority
Projects
None yet
Development

No branches or pull requests

5 participants