Skip to main content

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__(out self)

Default constructor for MojoValue.

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

Creates Type erased Mojo Value from T.

Args:

  • val (T): Object to type erase.

__moveinit__

__moveinit__(out self, owned existing: Self)

Move constructor for AnyMojoValue.

Args:

  • existing (Self): Instance to move from.

__del__

__del__(owned self)

Destructor for AnyMojoValue.

take

take(inout self) -> Self

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

Returns:

An instance of AnyMojoValue.

to

to[T: Movable](owned 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.