Skip to main content

Plain

Trait Plain 

Source
pub unsafe trait Plain: Copy + 'static { }
Expand description

A type for which every bit pattern of its size is a valid value, so it can be read from and written to the target’s memory without checks.

Implemented for integers, floats, raw pointers to sized types, the string types and arrays of plain types; generated bindings add enum newtypes and all-plain structs and unions. bool, function pointers and references have invalid bit patterns, so they aren’t plain.

§Safety

Every bit pattern of size_of::<Self>() bytes must be a valid value of Self.

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 Plain for f32

Source§

impl Plain for f64

Source§

impl Plain for i8

Source§

impl Plain for i16

Source§

impl Plain for i32

Source§

impl Plain for i64

Source§

impl Plain for i128

Source§

impl Plain for isize

Source§

impl Plain for u8

Source§

impl Plain for u16

Source§

impl Plain for u32

Source§

impl Plain for u64

Source§

impl Plain for u128

Source§

impl Plain for usize

Source§

impl<T: 'static> Plain for *const T

Source§

impl<T: 'static> Plain for *mut T

Source§

impl<T: Plain, const N: usize> Plain for [T; N]

Implementors§

Source§

impl Plain for CStrPtr

Source§

impl Plain for WStrPtr

Source§

impl<const N: usize> Plain for CStrBuf<N>

Source§

impl<const N: usize> Plain for WStrBuf<N>