Skip to main content

CReprOf

Trait CReprOf 

Source
pub trait CReprOf<T>: Sized + CDrop {
    // Required method
    fn c_repr_of(input: T) -> Result<Self, CReprOfError>;
}
Expand description

Consuming conversion from an idiomatic Rust value to its #[repr(C)] mirror.

Implementing CReprOf<U> for T states that T is a C-compatible layout of the Rust value U and that a T can be built from a U. The resulting T owns any heap memory it allocates, and that memory is reclaimed by the corresponding CDrop implementation.

see Deriving the traits.

Required Methods§

Source

fn c_repr_of(input: T) -> Result<Self, CReprOfError>

Consume input and return its C-compatible representation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl CReprOf<String> for CString

Source§

impl CReprOf<bool> for bool

Source§

impl CReprOf<f32> for f32

Source§

impl CReprOf<f64> for f64

Source§

impl CReprOf<i8> for i8

Source§

impl CReprOf<i16> for i16

Source§

impl CReprOf<i32> for i32

Source§

impl CReprOf<i64> for i64

Source§

impl CReprOf<u8> for u8

Source§

impl CReprOf<u16> for u16

Source§

impl CReprOf<u32> for u32

Source§

impl CReprOf<u64> for u64

Source§

impl CReprOf<usize> for i32

Source§

impl CReprOf<usize> for usize

Source§

impl<U, T: CReprOf<U>, const N: usize> CReprOf<[U; N]> for [T; N]
where [T; N]: CDrop,

Implementors§