Mojo function
rebind
rebind[src_type: TrivialRegisterPassable, //, dest_type: TrivialRegisterPassable](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 (
TrivialRegisterPassable): The original type. - dest_type (
TrivialRegisterPassable): The type to rebind to.
Args:
- src (
src_type): The value to rebind.
Returns:
dest_type: 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:
Args:
- src (
src_type): The value to rebind.
Returns:
ref: 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!