rune::runtime

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§

impl TypeHash for bool

Source§

impl TypeHash for char

Source§

impl TypeHash for f32

Source§

impl TypeHash for f64

Source§

impl TypeHash for i8

Source§

impl TypeHash for i16

Source§

impl TypeHash for i32

Source§

impl TypeHash for i64

Source§

impl TypeHash for i128

Source§

impl TypeHash for isize

Source§

impl TypeHash for str

Source§

impl TypeHash for u8

Source§

impl TypeHash for u16

Source§

impl TypeHash for u32

Source§

impl TypeHash for u64

Source§

impl TypeHash for u128

Source§

impl TypeHash for ()

Source§

impl TypeHash for usize

Source§

impl TypeHash for Error

Source§

impl TypeHash for String

Available on crate feature alloc only.
Source§

impl TypeHash for ParseCharError

Source§

impl TypeHash for Error

Source§

impl TypeHash for ParseFloatError

Source§

impl TypeHash for ParseIntError

Source§

impl TypeHash for Utf8Error

Source§

impl TypeHash for Error

Available on crate feature std only.
Source§

impl TypeHash for [u8]

Source§

impl TypeHash for [Value]

Source§

impl<A> TypeHash for (A,)

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

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§

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§

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§

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§

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§

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§

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§

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

Source§

impl<T> TypeHash for Option<T>

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§

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

Available on crate feature std only.
Source§

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

Available on crate feature std only.
Source§

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

Implementors§

Source§

impl TypeHash for rune::runtime::ControlFlow

Source§

impl TypeHash for GeneratorState

Source§

impl TypeHash for FromUtf8Error

Available on crate feature alloc only.
Source§

impl TypeHash for Box<str>

Source§

impl TypeHash for rune::alloc::String

Source§

impl TypeHash for Bencher

Source§

impl TypeHash for Format

Source§

impl TypeHash for Bytes

Source§

impl TypeHash for Formatter

Source§

impl TypeHash for Function

Source§

impl TypeHash for Future

Source§

impl TypeHash for Generator<Vm>

Source§

impl TypeHash for Hasher

Source§

impl TypeHash for Object

Source§

impl TypeHash for OwnedTuple

Source§

impl TypeHash for Range

Source§

impl TypeHash for RangeFrom

Source§

impl TypeHash for RangeFull

Source§

impl TypeHash for RangeInclusive

Source§

impl TypeHash for RangeTo

Source§

impl TypeHash for RangeToInclusive

Source§

impl TypeHash for Stream<Vm>

Source§

impl TypeHash for Tuple

Source§

impl TypeHash for Type

Source§

impl TypeHash for rune::runtime::Vec

Source§

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

Source§

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

Source§

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

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>