-
-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
as_ptr() returns a *mut _ pointer. This isn't an error by itself, but under Rust's memory model, this pointer is derived from shared/immutable &self, and therefore doesn't have permission to mutate self, so the mut of the pointer is misleading.
| fn as_ptr(&self) -> *mut Self::CType { |
I assume this is for convenience, because C APIs aren't diligent about const vs mut distinction. However, this is a gotcha, because C APIs that take *mut may actually mutate the object, and that is UB from Rust's perspective.
Could you add .as_mut_ptr() that takes &mut self to provide a pointer safe for mutation?
Metadata
Metadata
Assignees
Labels
No labels