rune

Trait TypeHash

Source
pub trait TypeHash {
    const HASH: Hash;
}
Expand description

Static type hash for a given type.

This trait allows you to determine the unique hash of any given type that can be used in Rune through the HASH associated constant.

This trait is usually implemented automatically through the Any derive.

A type hash is unique for types which in Rune are considered the same. This might not be true for types in Rust. For example, &str and String have the same type hash:

use rune::TypeHash;

assert_eq!(<&str>::HASH, String::HASH);

Required Associated Constants§

Source

const HASH: Hash

The complete type hash of the type including type parameters which uniquely identifiers a given type.

§Examples
use rune::TypeHash;

assert_ne!(String::HASH, i64::HASH);

fn is_a_string<T>() -> bool where T: TypeHash {
    matches!(T::HASH, String::HASH)
}

assert!(is_a_string::<String>());
assert!(!is_a_string::<i64>());

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 TypeHash for Ordering

Source§

const HASH: Hash = _

Source§

impl TypeHash for bool

Source§

const HASH: Hash = _

Source§

impl TypeHash for char

Source§

const HASH: Hash = _

Source§

impl TypeHash for f32

Source§

const HASH: Hash = _

Source§

impl TypeHash for f64

Source§

const HASH: Hash = _

Source§

impl TypeHash for i8

Source§

const HASH: Hash = _

Source§

impl TypeHash for i16

Source§

const HASH: Hash = _

Source§

impl TypeHash for i32

Source§

const HASH: Hash = _

Source§

impl TypeHash for i64

Source§

const HASH: Hash = _

Source§

impl TypeHash for i128

Source§

const HASH: Hash = _

Source§

impl TypeHash for isize

Source§

const HASH: Hash = _

Source§

impl TypeHash for str

Source§

const HASH: Hash = _

Source§

impl TypeHash for u8

Source§

const HASH: Hash = _

Source§

impl TypeHash for u16

Source§

const HASH: Hash = _

Source§

impl TypeHash for u32

Source§

const HASH: Hash = _

Source§

impl TypeHash for u64

Source§

const HASH: Hash = _

Source§

impl TypeHash for u128

Source§

const HASH: Hash = _

Source§

impl TypeHash for ()

Source§

const HASH: Hash = _

Source§

impl TypeHash for usize

Source§

const HASH: Hash = _

Source§

impl TypeHash for Error

Source§

const HASH: Hash = _

Source§

impl TypeHash for String

Available on crate feature alloc only.
Source§

const HASH: Hash = _

Source§

impl TypeHash for ParseCharError

Source§

const HASH: Hash = _

Source§

impl TypeHash for Error

Source§

const HASH: Hash = _

Source§

impl TypeHash for ParseFloatError

Source§

const HASH: Hash = _

Source§

impl TypeHash for ParseIntError

Source§

const HASH: Hash = _

Source§

impl TypeHash for Utf8Error

Source§

const HASH: Hash = _

Source§

impl TypeHash for Error

Available on crate feature std only.
Source§

const HASH: Hash = _

Source§

impl TypeHash for [u8]

Source§

const HASH: Hash = _

Source§

impl TypeHash for [Value]

Source§

const HASH: Hash = _

Source§

impl<A> TypeHash for (A,)

Source§

const HASH: Hash = _

Source§

impl<A, B> TypeHash for (A, B)

Source§

const HASH: Hash = _

Source§

impl<A, B, C> TypeHash for (A, B, C)

Source§

const HASH: Hash = _

Source§

impl<A, B, C, D> TypeHash for (A, B, C, D)

Source§

const HASH: Hash = _

Source§

impl<A, B, C, D, E> TypeHash for (A, B, C, D, E)

Source§

const HASH: Hash = _

Source§

impl<A, B, C, D, E, F> TypeHash for (A, B, C, D, E, F)

Source§

const HASH: Hash = _

Source§

impl<A, B, C, D, E, F, G> TypeHash for (A, B, C, D, E, F, G)

Source§

const HASH: Hash = _

Source§

impl<A, B, C, D, E, F, G, H> TypeHash for (A, B, C, D, E, F, G, H)

Source§

const HASH: Hash = _

Source§

impl<A, B, C, D, E, F, G, H, I> TypeHash for (A, B, C, D, E, F, G, H, I)

Source§

const HASH: Hash = _

Source§

impl<A, B, C, D, E, F, G, H, I, J> TypeHash for (A, B, C, D, E, F, G, H, I, J)

Source§

const HASH: Hash = _

Source§

impl<A, B, C, D, E, F, G, H, I, J, K> TypeHash for (A, B, C, D, E, F, G, H, I, J, K)

Source§

const HASH: Hash = _

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L> TypeHash for (A, B, C, D, E, F, G, H, I, J, K, L)

Source§

const HASH: Hash = _

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M> TypeHash for (A, B, C, D, E, F, G, H, I, J, K, L, M)

Source§

const HASH: Hash = _

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N> TypeHash for (A, B, C, D, E, F, G, H, I, J, K, L, M, N)

Source§

const HASH: Hash = _

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> TypeHash for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)

Source§

const HASH: Hash = _

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> TypeHash for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)

Source§

const HASH: Hash = _

Source§

impl<C, B> TypeHash for ControlFlow<C, B>

Source§

const HASH: Hash = _

Source§

impl<T> TypeHash for Option<T>

Source§

const HASH: Hash = _

Source§

impl<T> TypeHash for &T
where T: ?Sized + TypeHash,

Blanket implementation for references.

Source§

const HASH: Hash = T::HASH

Source§

impl<T> TypeHash for &mut T
where T: ?Sized + TypeHash,

Blanket implementation for mutable references.

Source§

const HASH: Hash = T::HASH

Source§

impl<T> TypeHash for Vec<T>

Available on crate feature alloc only.
Source§

const HASH: Hash = _

Source§

impl<T> TypeHash for HashMap<String, T>

Available on crate feature std only.
Source§

const HASH: Hash = _

Source§

impl<T> TypeHash for HashMap<String, T>

Available on crate feature std only.
Source§

const HASH: Hash = _

Source§

impl<T, E> TypeHash for Result<T, E>

Source§

const HASH: Hash = _

Implementors§

Source§

impl TypeHash for rune::runtime::ControlFlow

Source§

const HASH: Hash = _

Source§

impl TypeHash for GeneratorState

Source§

const HASH: Hash = _

Source§

impl TypeHash for FromUtf8Error

Available on crate feature alloc only.
Source§

const HASH: Hash = _

Source§

impl TypeHash for Box<str>

Source§

const HASH: Hash = _

Source§

impl TypeHash for rune::alloc::String

Source§

const HASH: Hash = _

Source§

impl TypeHash for Bencher

Source§

const HASH: Hash = _

Source§

impl TypeHash for Format

Source§

const HASH: Hash = _

Source§

impl TypeHash for Bytes

Source§

const HASH: Hash = _

Source§

impl TypeHash for Formatter

Source§

const HASH: Hash = _

Source§

impl TypeHash for Function

Source§

const HASH: Hash = _

Source§

impl TypeHash for Future

Source§

const HASH: Hash = _

Source§

impl TypeHash for Generator<Vm>

Source§

const HASH: Hash = _

Source§

impl TypeHash for Hasher

Source§

const HASH: Hash = _

Source§

impl TypeHash for Object

Source§

const HASH: Hash = _

Source§

impl TypeHash for OwnedTuple

Source§

const HASH: Hash = _

Source§

impl TypeHash for Range

Source§

const HASH: Hash = _

Source§

impl TypeHash for RangeFrom

Source§

const HASH: Hash = _

Source§

impl TypeHash for RangeFull

Source§

const HASH: Hash = _

Source§

impl TypeHash for RangeInclusive

Source§

const HASH: Hash = _

Source§

impl TypeHash for RangeTo

Source§

const HASH: Hash = _

Source§

impl TypeHash for RangeToInclusive

Source§

const HASH: Hash = _

Source§

impl TypeHash for Stream<Vm>

Source§

const HASH: Hash = _

Source§

impl TypeHash for Tuple

Source§

const HASH: Hash = _

Source§

impl TypeHash for Type

Source§

const HASH: Hash = _

Source§

impl TypeHash for rune::runtime::Vec

Source§

const HASH: Hash = _

Source§

impl<T> TypeHash for rune::alloc::HashMap<String, T>

Source§

const HASH: Hash = _

Source§

impl<T> TypeHash for rune::alloc::HashMap<String, T>

Source§

const HASH: Hash = _

Source§

impl<T> TypeHash for rune::alloc::Vec<T>

Source§

const HASH: Hash = _

Source§

impl<T> TypeHash for Mut<T>
where T: ?Sized + TypeHash,

Blanket implementation for owned mutable references.

Source§

const HASH: Hash = T::HASH

Source§

impl<T> TypeHash for Ref<T>
where T: ?Sized + TypeHash,

Blanket implementation for owned references.

Source§

const HASH: Hash = T::HASH

Source§

impl<T> TypeHash for VecTuple<T>

Source§

const HASH: Hash = _