Skip to main content
Log in

Mojo struct

AnyMojoValue

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, UnknownDestructibility

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.

copy

copy(self) -> Self

Explicitly construct a copy of self.

Returns:

A copy of this value.

take

take(mut self) -> Self

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

Returns:

An instance of AnyMojoValue.

to

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

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.