UsizeAssert

Trait UsizeAssert 

Source
pub unsafe trait UsizeAssert: Sized {
    type Type;

    const LHS: usize;
    const RHS: usize;
    const COMPARE: Comparison;
    const PROPERTY: &'static str;
    const FAILED: bool = _;

    // Provided method
    fn assert() { ... }
}
Expand description

Compile time evaluable assert for usize values.

See module docs for what happens when an assertion fails.

§Safety

Self::assert() and Self::FAILED must keep the default implementation.

Required Associated Constants§

Source

const LHS: usize

Left hand side of the comparison.

This is the value the type has.

Source

const RHS: usize

Right hand side of the comparison.

This is the value to check against.

Source

const COMPARE: Comparison

Type of comparison to make between Self::LHS and Self::RHS.

Source

const PROPERTY: &'static str

Same of the property being checked.

This is printed in the failure message.

Provided Associated Constants§

Source

const FAILED: bool = _

Associated constant used to trigger compile time errors.

By making rustc evaluate this constant, you can trigger a compile time error.

See module docs for details.

Required Associated Types§

Source

type Type

Type with the property being checked.

Provided Methods§

Source

fn assert()

Assert the defined comparison is true.

§Panics

This function will panic if the DUNGEON_CELL_RUNTIME_CHECKS environment variable is set and the assertion fails. Otherwise, this function is a no-op for the program.

See module docs for details.

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.

Implementors§

Source§

impl<T, Alignment: IsAlignment> UsizeAssert for AlignmentSmallerOrEqualTo<T, Alignment>

Source§

const LHS: usize

Source§

const RHS: usize = Alignment::VALUE

Source§

const COMPARE: Comparison = Comparison::LessThanEqual

Source§

const PROPERTY: &'static str = "alignment"

Source§

type Type = T

Source§

impl<T, Size: IsSize> UsizeAssert for SizeSmallerOrEqualTo<T, Size>

Source§

const LHS: usize

Source§

const RHS: usize = Size::VALUE

Source§

const COMPARE: Comparison = Comparison::LessThanEqual

Source§

const PROPERTY: &'static str = "size"

Source§

type Type = T