pub trait BorrowForeign<'a>: FreeForeign {
type Storage: 'a;
// Required method
fn borrow_foreign(
&'a self,
) -> BorrowedPointer<'a, Self::Foreign, Self::Storage>;
}Expand description
A type for which a C representation can be borrowed without cloning.
Required Associated Types§
Required Methods§
Sourcefn borrow_foreign(&'a self) -> BorrowedPointer<'a, Self::Foreign, Self::Storage>
fn borrow_foreign(&'a self) -> BorrowedPointer<'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 constant pointer.
let s = CString::new("Hello, world!").unwrap();
let borrowed = s.borrow_foreign();
let len = unsafe { libc::strlen(borrowed.as_ptr()) };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.