Skip to main content

Mojo function

rebind_var

rebind_var[src_type: Movable, //, dest_type: Movable](var src: src_type, out dest: 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 owned variable with an adjusted type.

Unlike rebind, this function takes an owned variable and returns an owned variable via moving the value from the input to the output.

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 (Movable): The original type.
  • โ€‹dest_type (Movable): The type to rebind to.

Args:

  • โ€‹src (src_type): The value to rebind.

Returns:

dest_type: An owned value rebound as dest_type.

Was this page helpful?