Skip to main content

Mojo function

trait_downcast_var

trait_downcast_var[T: Movable, //, Trait: AnyTrait[Movable]](var src: T) -> T(Trait)

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.

Parameters:

  • โ€‹T (Movable): The original type (inferred).
  • โ€‹Trait (AnyTrait): The trait to downcast into.

Args:

  • โ€‹src (T): The value to downcast.

Returns:

T(Trait): The downcasted value.

Was this page helpful?