Skip to main content
Log in

Mojo struct

AnyMojoValue

Type erased representation of a mojo object. This is useful for passing opaque type as input for graph executution.

CAUTION: Experimental API.

Aliases​

  • c_type = _CMojoValue:

Implemented traits​

AnyType, CollectionElement, Copyable, Movable

Methods​

__init__​

__init__(inout self: Self)

Default constructor for MojoValue.

__init__[T: Movable](inout self: Self, owned val: T)

Creates Type erased Mojo Value from T.

Args:

  • ​val (T): Object to type erase.

__moveinit__​

__moveinit__(inout self: Self, owned existing: Self)

Move constructor for AnyMojoValue.

Args:

  • ​existing (Self): Instance to move from.

__del__​

__del__(owned self: Self)

Destructor for AnyMojoValue.

take​

take(inout self: Self) -> Self

Returns the current value and initializes this object to default state.

Returns:

An instance of AnyMojoValue.

to​

to[T: Movable](owned self: Self) -> $0

Consume this object and produces an instance of T. This doesn't do any type check and assumes this AnyMojoValue was created from T.

Returns:

Instance of type T.

Was this page helpful?