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§
Sourceconst KEY_TYPE: IntegerType
const KEY_TYPE: IntegerType
The corresponding IntegerType of this key
const MAX_USIZE_VALUE: usize
Provided Methods§
Sourceunsafe fn as_usize(self) -> usize
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.
Sourceunsafe fn from_usize_unchecked(x: usize) -> Self
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.
Sourcefn always_fits_usize() -> bool
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.