Mojo module
rebind
Implements type rebind/trait downcast
These are Mojo built-ins, so you don't need to import them.
comptime values
downcast
comptime downcast[_Trait: AnyTrait[UnknownDestructibility], T: UnknownDestructibility] = T(_Trait)
Type alias for downcasting a type to conform to a trait.
Parameters
- _Trait (
AnyTrait): The trait type to downcast to. - T (
UnknownDestructibility): The type to downcast.
Functions
-
rebind: Statically assert that a parameter input typesrc_typeresolves to the same type as a parameter result typedest_typeafter function instantiation and "rebind" the input to the result type. -
rebind_var: Statically assert that a parameter input typesrc_typeresolves to the same type as a parameter result typedest_typeafter function instantiation and "rebind" the input to the result type, returning a owned variable with an adjusted type. -
trait_downcast: Downcast a parameter input typeTand rebind the type such that the return value's type conforms the providedTrait. IfT, after resolving to a concrete type, does not actually conform toTrait, a compilation error would occur.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!