use crate::{
export,
runtime::{
ops::ScriptNone,
Downcast,
Origin,
Provider,
RuntimeResult,
ScriptType,
TypeHint,
Upcast,
},
};
#[export(include)]
#[export(name "nil")]
type UnitType = ();
impl<'a> Downcast<'a> for UnitType {
#[inline(always)]
fn downcast(origin: Origin, provider: Provider<'a>) -> RuntimeResult<Self> {
provider.to_owned().take::<UnitType>(origin)
}
#[inline(always)]
fn hint() -> TypeHint {
TypeHint::Type(UnitType::type_meta())
}
}
impl<'a> Downcast<'a> for &'a UnitType {
#[inline(always)]
fn downcast(origin: Origin, provider: Provider<'a>) -> RuntimeResult<Self> {
provider
.to_borrowed(&origin)?
.borrow_ref::<UnitType>(origin)
}
#[inline(always)]
fn hint() -> TypeHint {
TypeHint::Type(UnitType::type_meta())
}
}
impl<'a> Downcast<'a> for &'a mut UnitType {
#[inline(always)]
fn downcast(origin: Origin, provider: Provider<'a>) -> RuntimeResult<Self> {
provider
.to_borrowed(&origin)?
.borrow_mut::<UnitType>(origin)
}
#[inline(always)]
fn hint() -> TypeHint {
TypeHint::Type(UnitType::type_meta())
}
}
impl<'a> Upcast<'a> for UnitType {
type Output = Self;
#[inline(always)]
fn upcast(_origin: Origin, _this: Self) -> RuntimeResult<Self::Output> {
Ok(())
}
#[inline(always)]
fn hint() -> TypeHint {
TypeHint::Type(UnitType::type_meta())
}
}
impl<'a> Upcast<'a> for &'a UnitType {
type Output = UnitType;
#[inline(always)]
fn upcast(_origin: Origin, _this: Self) -> RuntimeResult<Self::Output> {
Ok(())
}
#[inline(always)]
fn hint() -> TypeHint {
TypeHint::Type(UnitType::type_meta())
}
}
impl<'a> Upcast<'a> for &'a mut UnitType {
type Output = UnitType;
#[inline(always)]
fn upcast(_origin: Origin, _this: Self) -> RuntimeResult<Self::Output> {
Ok(())
}
#[inline(always)]
fn hint() -> TypeHint {
TypeHint::Type(UnitType::type_meta())
}
}
#[export(include)]
impl ScriptNone for UnitType {}