Skip to main content

DictionaryKey

Trait DictionaryKey 

Source
pub unsafe trait DictionaryKey:
    NativeType
    + TryInto<usize>
    + TryFrom<usize>
    + Hash {
    const KEY_TYPE: IntegerType;
    const MAX_USIZE_VALUE: usize;

    // Provided methods
    unsafe fn as_usize(self) -> usize { ... }
    unsafe fn from_usize_unchecked(x: usize) -> Self { ... }
    fn always_fits_usize() -> bool { ... }
}
Expand description

Trait denoting NativeTypes that can be used as keys of a dictionary.

§Safety

Any implementation of this trait must ensure that always_fits_usize only returns true if all values succeeds on value::try_into::<usize>().unwrap().

Required Associated Constants§

Source

const KEY_TYPE: IntegerType

The corresponding IntegerType of this key

Source

const MAX_USIZE_VALUE: usize

Provided Methods§

Source

unsafe fn as_usize(self) -> usize

Represents this key as a usize.

§Safety

The caller must have checked that the value can be cast to usize.

Source

unsafe fn from_usize_unchecked(x: usize) -> Self

Create a key from a usize without checking bounds.

§Safety

The caller must have checked that the value can be created from a usize.

Source

fn always_fits_usize() -> bool

If the key type always can be converted to usize.

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 DictionaryKey for i8

Source§

impl DictionaryKey for i16

Source§

const KEY_TYPE: IntegerType = IntegerType::Int16

Source§

const MAX_USIZE_VALUE: usize

Source§

impl DictionaryKey for i32

Source§

const KEY_TYPE: IntegerType = IntegerType::Int32

Source§

const MAX_USIZE_VALUE: usize

Source§

impl DictionaryKey for i64

Source§

const KEY_TYPE: IntegerType = IntegerType::Int64

Source§

const MAX_USIZE_VALUE: usize

Source§

impl DictionaryKey for i128

Source§

const KEY_TYPE: IntegerType = IntegerType::Int128

Source§

const MAX_USIZE_VALUE: usize

Source§

impl DictionaryKey for u8

Source§

impl DictionaryKey for u16

Source§

impl DictionaryKey for u32

Source§

impl DictionaryKey for u64

Source§

impl DictionaryKey for u128

Source§

const KEY_TYPE: IntegerType = IntegerType::UInt128

Source§

const MAX_USIZE_VALUE: usize

Implementors§