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

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

Parameters

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.

Was this page helpful?