Trait BorrowForeignMut

Source
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§

Source

type Storage: 'a

The type of any extra data that are needed while the BorrowedMutPointer is alive.

Required Methods§

Source

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.

Implementations on Foreign Types§

Source§

impl<'a> BorrowForeignMut<'a> for bool

Source§

type Storage = &'a mut bool

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a> BorrowForeignMut<'a> for f32

Source§

type Storage = &'a mut f32

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a> BorrowForeignMut<'a> for f64

Source§

type Storage = &'a mut f64

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a> BorrowForeignMut<'a> for i8

Source§

type Storage = &'a mut i8

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a> BorrowForeignMut<'a> for i16

Source§

type Storage = &'a mut i16

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a> BorrowForeignMut<'a> for i32

Source§

type Storage = &'a mut i32

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a> BorrowForeignMut<'a> for i64

Source§

type Storage = &'a mut i64

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a> BorrowForeignMut<'a> for isize

Source§

type Storage = &'a mut isize

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a> BorrowForeignMut<'a> for u8

Source§

type Storage = &'a mut u8

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a> BorrowForeignMut<'a> for u16

Source§

type Storage = &'a mut u16

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a> BorrowForeignMut<'a> for u32

Source§

type Storage = &'a mut u32

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a> BorrowForeignMut<'a> for u64

Source§

type Storage = &'a mut u64

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a> BorrowForeignMut<'a> for usize

Source§

type Storage = &'a mut usize

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a, T> BorrowForeignMut<'a> for Option<T>
where T: BorrowForeignMut<'a>,

Source§

impl<'a, T> BorrowForeignMut<'a> for [T]
where T: FixedAlloc + FreeForeign<Foreign = T> + BorrowForeignMut<'a, Storage = &'a mut T> + 'a,

Source§

type Storage = &'a mut [T]

Source§

fn borrow_foreign_mut( &mut self, ) -> BorrowedMutPointer<'_, Self::Foreign, &mut Self>

Source§

impl<'a, T> BorrowForeignMut<'a> for Box<T>
where T: BorrowForeignMut<'a>,

Source§

type Storage = <T as BorrowForeignMut<'a>>::Storage

Source§

fn borrow_foreign_mut( &'a mut self, ) -> BorrowedMutPointer<'a, Self::Foreign, Self::Storage>

Source§

impl<'a, T> BorrowForeignMut<'a> for Vec<T>
where [T]: BorrowForeignMut<'a>,

Implementors§