Trait Pessimize

Source
pub unsafe trait Pessimize {
    // Required methods
    fn hide(self) -> Self;
    fn assume_read(&self);
    fn assume_accessed(&mut self);
    fn assume_accessed_imut(&self);
}
Expand description

Optimization barriers provided by this crate

This trait is implemented for both value and reference types, which can lead to unexpected method syntax semantics (you expected to call the Pessimize impl of T, and you actually called that of &T). As a result, it is strongly recommended to use the optimization barriers via the free functions provided at the crate root, rather than via method syntax.

Implementing Pessimize requires fairly tricky code. Consider implementing PessimizeCast and BorrowPessimize instead, which is slightly easier, and will lead to an automatic Pessimize implementation.

§Safety

Unsafe code may rely on hide() behaving as an identity function (returning the input value unaltered) and assume_xyz() not altering anything even if the type is internally mutable.

Required Methods§

Source

fn hide(self) -> Self

See pessimize::hide() for documentation

Source

fn assume_read(&self)

See pessimize::assume_read() for documentation

Source

fn assume_accessed(&mut self)

See pessimize::assume_accessed() for documentation

Source

fn assume_accessed_imut(&self)

See pessimize::assume_accessed_imut() for documentation

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

Source§

impl Pessimize for f64

Source§

impl Pessimize for i8

Source§

impl Pessimize for i16

Source§

impl Pessimize for i32

Source§

impl Pessimize for i64

Source§

impl Pessimize for isize

Source§

impl Pessimize for u8

Source§

impl Pessimize for u16

Source§

impl Pessimize for u32

Source§

impl Pessimize for u64

Source§

impl Pessimize for ()

Source§

impl Pessimize for usize

Source§

impl Pessimize for float64x1_t

Available with target feature neon only.
Source§

impl Pessimize for float64x2_t

Available with target feature neon only.
Source§

impl Pessimize for System

Available on crate feature std only.
Source§

impl<A1: Pessimize, A2: Pessimize, A3: Pessimize, A4: Pessimize, A5: Pessimize, A6: Pessimize, A7: Pessimize, A8: Pessimize> Pessimize for (A1, A2, A3, A4, A5, A6, A7, A8)

Source§

impl<A2: Pessimize, A3: Pessimize, A4: Pessimize, A5: Pessimize, A6: Pessimize, A7: Pessimize, A8: Pessimize> Pessimize for (A2, A3, A4, A5, A6, A7, A8)

Source§

impl<A3: Pessimize, A4: Pessimize, A5: Pessimize, A6: Pessimize, A7: Pessimize, A8: Pessimize> Pessimize for (A3, A4, A5, A6, A7, A8)

Source§

impl<A4: Pessimize, A5: Pessimize, A6: Pessimize, A7: Pessimize, A8: Pessimize> Pessimize for (A4, A5, A6, A7, A8)

Source§

impl<A5: Pessimize, A6: Pessimize, A7: Pessimize, A8: Pessimize> Pessimize for (A5, A6, A7, A8)

Source§

impl<A6: Pessimize, A7: Pessimize, A8: Pessimize> Pessimize for (A6, A7, A8)

Source§

impl<A7: Pessimize, A8: Pessimize> Pessimize for (A7, A8)

Source§

impl<A8: Pessimize> Pessimize for (A8,)

Source§

impl<T: Copy + Pessimize> Pessimize for Cell<T>

Source§

impl<T: Pointee + ?Sized> Pessimize for *const T
where T::Metadata: Pessimize,

Available on crate feature nightly only.
Source§

impl<T: Pessimize + Read> Pessimize for Take<T>

Available on crate feature std and 64-bit only.
Source§

impl<T: Pessimize> Pessimize for Cursor<T>

Available on crate feature std and 64-bit only.
Source§

impl<T: ?Sized> Pessimize for DynMetadata<T>

Available on crate feature nightly only.

Implementors§

Source§

impl<T> Pessimize for T

Available on crate features nightly and default_impl only.
Source§

impl<T: BorrowPessimize> Pessimize for T