Mojo function
rebind
rebind[src_type: AnyTrivialRegType, //, dest_type: AnyTrivialRegType](src: src_type) -> dest_type
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.
This function is meant to be used in uncommon cases where a parametric type depends on the value of a constrained parameter in order to manually refine the type with the constrained parameter value.
Parameters:
- src_type (
AnyTrivialRegType
): The original type. - dest_type (
AnyTrivialRegType
): The type to rebind to.
Args:
- src (
src_type
): The value to rebind.
Returns:
The rebound value of dest_type
.
rebind[src_type: AnyType, //, dest_type: AnyType](ref src: src_type) -> ref [src] dest_type
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 reference to the input value with an adjusted type.
This function is meant to be used in uncommon cases where a parametric type depends on the value of a constrained parameter in order to manually refine the type with the constrained parameter value.
Parameters:
- src_type (
AnyType
): The original type. - dest_type (
AnyType
): The type to rebind to.
Args:
- src (
src_type
): The value to rebind.
Returns:
A reference to the value rebound as dest_type
.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!