Skip to main content

Mojo trait

RegisterPassable

A marker trait to denote the type to be register passable.

The compiler treats the type that conforms to this trait with the following constraints:

  • the value struct doesn’t have “identity” - you can’t take the address of self on read convention methods. This is allows the compiler to pass it in registers.

  • The type implicitly conforms to Movable and the compiler synthesizes a trivial move constructor. The compiler needs to be able to move around values of the type by loading and storing them. A custom move constructor is not allowed.

  • Compiler checks that any stored member (vars) also conforms to this trait. It wouldn’t be possible to provide identity for a contained member if the container doesn’t have identity.

  • The type can choose whether it wants to be Copyable or not.

struct Foo(RegisterPassable):
   ...

Implemented traits

AnyType, Movable

Required methods

__init__

__init__(out self: _Self, *, deinit take: _Self)

Create a new instance of the value by moving the value of another.

Args:

  • take (_Self): The value to move.

Returns:

_Self

Was this page helpful?