pub unsafe trait IsJanetAbstract {
type Get: IsJanetAbstract;
const SIZE: usize;
// Required method
fn type_info() -> &'static JanetAbstractType;
}
Expand description
The trait that encodes the information required to instantiate the implementer as
JanetAbstract
.
§Safety
Implementing this trait is not trivial if the type implements Drop
and can cause
undefined behavior if not implemented carefully.
Usually that can be solved by defining Get
as a
ManuallyDrop<Self>
. But in that case, you also become responsible to define
JanetAbstractType::gc
function to properly handle the dropping of the type for the
Janet-side.
Required Associated Constants§
Sourceconst SIZE: usize
const SIZE: usize
The size of the type that is being transformed as JanetAbstract
.
Usually mem::size_of<Self>()
Required Associated Types§
Sourcetype Get: IsJanetAbstract
type Get: IsJanetAbstract
The type that you get when you call JanetAbstract::get
family of functions.
This is usually set to Self
when the type does not implement Drop
, or
ManuallyDrop<Self>
if the type implements Drop
.
Required Methods§
Sourcefn type_info() -> &'static JanetAbstractType
fn type_info() -> &'static JanetAbstractType
Returns the table of the name of the Self
and all possible polymorphic function
pointer that a Abstract type can have in Janet.
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.