Struct CopyOptimization

Source
pub struct CopyOptimization<T: ?Sized, U: ?Sized>(/* private fields */);
Expand description

An optimization hint about whether the conversion from T to U is equivalent to copying the raw bytes of T.

Implementations§

Source§

impl<T: ?Sized, U: ?Sized> CopyOptimization<T, U>

Source

pub const unsafe fn enable() -> Self

Returns a CopyOptimization hint with the optimization enabled.

§Safety

T and U must be the same size and must not have any uninit bytes (e.g. padding).

Source

pub const unsafe fn enable_if(value: bool) -> Self

Returns a CopyOptimization hint with the optimization enabled if value is true.

§Safety

T and U must be the same size and must not have any uninit bytes (e.g. padding) if value is true.

Source

pub const fn disable() -> Self

Returns a CopyOptimization hint with the optimization disabled.

Source

pub const fn is_enabled(&self) -> bool

Returns whether the optimization is enabled.

Source

pub const fn infer_array<const N: usize>( &self, ) -> CopyOptimization<[T; N], [U; N]>
where T: Sized, U: Sized,

Infers whether the conversion from [T; N] to [U; N] is copy-optimizable based on the conversion from T to U.

Source

pub const fn infer_slice(&self) -> CopyOptimization<[T], [U]>
where T: Sized, U: Sized,

Infers whether the conversion from [T] to [U] is copy-optimizable based on the conversion from T to U.

Source§

impl<T: ?Sized> CopyOptimization<T, T>

Source

pub const fn identity() -> Self

Returns an enabled CopyOptimization, as copy optimization is always enabled from a type to itself.

Source§

impl CopyOptimization<(), ()>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<bool, bool>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<i8, i8>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireI16, WireI16>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<i16, WireI16>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireI16, i16>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireI32, WireI32>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<i32, WireI32>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireI32, i32>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireI64, WireI64>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<i64, WireI64>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireI64, i64>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<u8, u8>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireU16, WireU16>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<u16, WireU16>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireU16, u16>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireU32, WireU32>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<u32, WireU32>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireU32, u32>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireU64, WireU64>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<u64, WireU64>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireU64, u64>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireF32, WireF32>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<f32, WireF32>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireF32, f32>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireF64, WireF64>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<f64, WireF64>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Source§

impl CopyOptimization<WireF64, f64>

Source

pub const PRIMITIVE: Self

Whether copy optimization between the two primitive types is enabled.

Auto Trait Implementations§

§

impl<T, U> Freeze for CopyOptimization<T, U>
where T: ?Sized, U: ?Sized,

§

impl<T, U> RefUnwindSafe for CopyOptimization<T, U>

§

impl<T, U> !Send for CopyOptimization<T, U>

§

impl<T, U> !Sync for CopyOptimization<T, U>

§

impl<T, U> Unpin for CopyOptimization<T, U>
where T: ?Sized, U: ?Sized,

§

impl<T, U> UnwindSafe for CopyOptimization<T, U>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.