IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

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[Movable]): The trait to downcast into.

Args:

  • src (T): The value to downcast.

Returns:

T(Trait): The downcasted value.