use crate::core::UntypedVal; /// Utility type used to convert between `reftype` and [`UntypedVal`]. /// /// # Note /// /// This is used for conversions of [`FuncRef`] and [`ExternRef`]. /// /// [`FuncRef`]: [`crate::FuncRef`] /// [`ExternRef`]: [`crate::ExternRef`] pub union Transposer { /// The `reftype` based representation. pub reftype: T, /// The integer based representation to model pointer types. pub value: u64, } impl Transposer { /// Creates a `null` [`Transposer`]. pub fn null() -> Self { Self { value: 0 } } } impl Transposer { /// Creates a new [`Transposer`] from the given `reftype`. pub fn new(reftype: T) -> Self { Transposer { reftype } } } impl From for Transposer { fn from(untyped: UntypedVal) -> Self { Transposer { value: u64::from(untyped), } } }