pub trait AsRawMut<T> {
// Required method
unsafe fn as_raw_mut(&mut self) -> &mut T;
}Expand description
Escape-hatch mutable access to a wrapper’s raw FFI value.
Implemented by every thin wrapper. For wrappers classified sound
(see the per-type // SOUNDNESS: comments at the make_thin_wrapper!
call sites) this duplicates AsMut; for readonly wrappers it is the
only mutable access to the raw struct — and it is unsafe, because
the wrapper’s safe API trusts invariants of the raw fields (issue #276).
Required Methods§
Sourceunsafe fn as_raw_mut(&mut self) -> &mut T
unsafe fn as_raw_mut(&mut self) -> &mut T
Mutable access to the wrapped raw FFI value.
§Safety
Callers must uphold the wrapper’s invariants:
- do not corrupt count/dimension/format fields that safe
accessors use to derive slice lengths or buffer sizes (e.g.
Mesh::vertexCount,Image::width/height/format), and - do not reassign pointer fields that are owned and freed by
Drop(e.g.Model::meshes,Font::glyphs), unless you take over ownership of the previous allocation.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".