use crate::runtime::{Mut, Ref, Shared, TypeInfo};
use crate::Hash;
#[doc(inline)]
pub use rune_core::FullTypeOf;
pub trait TypeOf {
#[inline]
fn type_of() -> FullTypeOf {
FullTypeOf::new(Self::type_hash())
}
#[inline]
fn type_parameters() -> Hash {
Hash::EMPTY
}
fn type_hash() -> Hash;
fn type_info() -> TypeInfo;
}
pub trait MaybeTypeOf {
fn maybe_type_of() -> Option<FullTypeOf>;
}
impl<T> MaybeTypeOf for &T
where
T: ?Sized + MaybeTypeOf,
{
#[inline]
fn maybe_type_of() -> Option<FullTypeOf> {
T::maybe_type_of()
}
}
impl<T> MaybeTypeOf for &mut T
where
T: ?Sized + MaybeTypeOf,
{
#[inline]
fn maybe_type_of() -> Option<FullTypeOf> {
T::maybe_type_of()
}
}
impl<T> MaybeTypeOf for Ref<T>
where
T: ?Sized + MaybeTypeOf,
{
#[inline]
fn maybe_type_of() -> Option<FullTypeOf> {
T::maybe_type_of()
}
}
impl<T> MaybeTypeOf for Mut<T>
where
T: ?Sized + MaybeTypeOf,
{
#[inline]
fn maybe_type_of() -> Option<FullTypeOf> {
T::maybe_type_of()
}
}
impl<T> MaybeTypeOf for Shared<T>
where
T: ?Sized + MaybeTypeOf,
{
#[inline]
fn maybe_type_of() -> Option<FullTypeOf> {
T::maybe_type_of()
}
}
impl<T> TypeOf for &T
where
T: ?Sized + TypeOf,
{
#[inline]
fn type_of() -> FullTypeOf {
T::type_of()
}
#[inline]
fn type_parameters() -> Hash {
T::type_parameters()
}
#[inline]
fn type_hash() -> Hash {
T::type_hash()
}
#[inline]
fn type_info() -> TypeInfo {
T::type_info()
}
}
impl<T> TypeOf for &mut T
where
T: ?Sized + TypeOf,
{
#[inline]
fn type_of() -> FullTypeOf {
T::type_of()
}
#[inline]
fn type_parameters() -> Hash {
T::type_parameters()
}
#[inline]
fn type_hash() -> Hash {
T::type_hash()
}
#[inline]
fn type_info() -> TypeInfo {
T::type_info()
}
}
impl<T> TypeOf for Ref<T>
where
T: ?Sized + TypeOf,
{
#[inline]
fn type_of() -> FullTypeOf {
T::type_of()
}
#[inline]
fn type_parameters() -> Hash {
T::type_parameters()
}
#[inline]
fn type_hash() -> Hash {
T::type_hash()
}
#[inline]
fn type_info() -> TypeInfo {
T::type_info()
}
}
impl<T> TypeOf for Mut<T>
where
T: ?Sized + TypeOf,
{
#[inline]
fn type_of() -> FullTypeOf {
T::type_of()
}
#[inline]
fn type_parameters() -> Hash {
T::type_parameters()
}
#[inline]
fn type_hash() -> Hash {
T::type_hash()
}
#[inline]
fn type_info() -> TypeInfo {
T::type_info()
}
}
impl<T> TypeOf for Shared<T>
where
T: ?Sized + TypeOf,
{
#[inline]
fn type_of() -> FullTypeOf {
T::type_of()
}
#[inline]
fn type_parameters() -> Hash {
T::type_parameters()
}
#[inline]
fn type_hash() -> Hash {
T::type_hash()
}
#[inline]
fn type_info() -> TypeInfo {
T::type_info()
}
}