For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
Origin
struct Origin[mut: Bool, _mlir_origin: LITOrigin[mut], //]
This represents a origin reference for a memory value.
Parameters
- mut (
Bool): Whether the origin is mutable. - _mlir_origin (
LITOrigin[mut]): The raw MLIR origin value.
Implemented traits
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDestructible,
Movable,
RegisterPassable,
TrivialRegisterPassable
comptime members
contains
comptime contains[element: Origin[mut=mut]] = Bool((origin_eq _mlir_origin == {_mlir_origin, _mlir_origin}))
Is true if self is a superset of element. This predicate can only be used in 'where' clauses and other expressions evaluated at parse time. It may not be used in 'comptime if' and similar expressions.
Parameters
- element (
Origin[mut=mut]): The origin to check if it is a subset of Self.
equals
comptime equals[rhs: Origin[mut=mut]] = Bool((origin_eq _mlir_origin == _mlir_origin))
Is true if self is equal to rhs. This predicate can only be used in 'where' clauses and other expressions evaluated at parse time. It may not be used in 'comptime if' and similar expressions.
Parameters
- rhs (
Origin[mut=mut]): The other origin to compare to.
Methods
__init__
__init__() -> Self
Construct an Origin.
@implicit
__init__(v: Origin[mut=v.mut]) -> ImmutOrigin
Implicitly convert an origin to an immutable one.
Args:
- v (
Origin[mut=v.mut]): The origin to convert.
Returns:
ImmutOrigin
unsafe_mut_cast
static unsafe_mut_cast[dest_mut: Bool]() -> Origin[mut=dest_mut]
Cast this origin to a different mutability, potentially introducing more mutability, which is an unsafe operation.
Parameters:
- dest_mut (
Bool): The desired mutability of the resulting origin.
Returns:
Origin[mut=dest_mut]: The same origin but with a new specified mutability.