Skip to main content

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[T: AnyType, _Trait: AnyTrait[AnyType]] = T(_Trait)

Type alias for downcasting a type to conform to a trait.

Parameters

  • T (AnyType): The type to downcast.
  • _Trait (AnyTrait): The trait type to downcast to.

Functions

  • rebind: Statically assert that a parameter input type src_type resolves to the same type as a parameter result type dest_type after function instantiation and "rebind" the input to the result type.
  • rebind_var: Statically assert that a parameter input type src_type resolves to the same type as a parameter result type dest_type after function instantiation and "rebind" the input to the result type, returning a owned variable with an adjusted type.
  • trait_downcast: Downcast a parameter input type T and rebind the type such that the return value's type conforms the provided Trait. If T, after resolving to a concrete type, does not actually conform to Trait, a compilation error would occur.
  • trait_downcast_var: Downcast a parameter input type T and rebind the type such that the return value's type conforms to the provided Trait. If T, after resolving to a concrete type, does not actually conform to Trait, a compilation error will occur.

Was this page helpful?