Mojo function
trait_downcast
trait_downcast[T: AnyTrivialRegType, //, Trait: AnyTrait[AnyType]](var src: T) -> downcast(:type T)
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.
Parameters:
- T (
AnyTrivialRegType
): The original type. - Trait (
AnyTrait
): The trait to downcast into.
Args:
- src (
T
): The value to downcast.
Returns:
downcast(:type T)
: The downcasted value.
trait_downcast[T: AnyType, //, Trait: AnyTrait[AnyType]](ref src: T) -> ref [src] downcast(:trait<_stdlib::_builtin::_anytype::_AnyType> T)
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.
Parameters:
- T (
AnyType
): The original type. - Trait (
AnyTrait
): The trait to downcast into.
Args:
- src (
T
): The value to downcast.
Returns:
ref
: The downcasted value.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!