pub trait BorrowForeignMut<'a>: FreeForeign {
type Storage: 'a;
// Required method
fn borrow_foreign_mut(
&'a mut self,
) -> BorrowedMutPointer<'a, Self::Foreign, Self::Storage>;
}Expand description
A type for which a C representation can be borrowed mutably without cloning.
Required Associated Types§
Required Methods§
Sourcefn borrow_foreign_mut(
&'a mut self,
) -> BorrowedMutPointer<'a, Self::Foreign, Self::Storage>
fn borrow_foreign_mut( &'a mut self, ) -> BorrowedMutPointer<'a, Self::Foreign, Self::Storage>
Return a wrapper for a C representation of self. The wrapper
borrows the data from self and allows access via a mutable pointer.
let mut i = 123i8;
let mut borrowed = i.borrow_foreign_mut();
unsafe {
assert_eq!(*borrowed.as_ptr(), 123i8);
*borrowed.as_mut_ptr() = 45i8;
}
assert_eq!(i, 45i8);is analogous to:
let mut i = 123i8;
let borrowed = &mut i;
assert_eq!(*borrowed, 123i8);
*borrowed = 45i8;
assert_eq!(i, 45i8);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.