pub struct CppMutRef<'a, T: ?Sized> { /* private fields */ }
Expand description
A C++ non-const reference. These are different from Rust’s &mut T
in that
several C++ references can exist to the same underlying data (“aliasing”)
and that’s not permitted for regular Rust references.
See CppRef
for details on safety, usage models and implementation.
You can convert this to a CppRef
using the std::convert::Into
trait.
Implementations§
Source§impl<T: ?Sized> CppMutRef<'_, T>
impl<T: ?Sized> CppMutRef<'_, T>
Sourcepub fn as_mut_ptr(&self) -> *mut T
pub fn as_mut_ptr(&self) -> *mut T
Retrieve the underlying C++ pointer.
Sourcepub unsafe fn as_mut(&mut self) -> &mut T
pub unsafe fn as_mut(&mut self) -> &mut T
Get a regular Rust mutable reference out of this C++ reference.
§Safety
Callers must guarantee that the referent is not modified by any other C++ or Rust code while the returned reference exists. Callers must also guarantee that no other Rust reference is created to the referent while the returned reference exists.
Callers must also be sure that the C++ reference is properly aligned, not null, pointing to valid data, etc.
Sourcepub fn lifetime_cast(&mut self) -> PhantomReferentMut<T>
pub fn lifetime_cast(&mut self) -> PhantomReferentMut<T>
Extend the lifetime of the returned reference beyond normal Rust
borrow checker rules. See CppRef::lifetime_cast
.