Mojo struct
Reference
Defines a non-nullable safe reference.
Parameters
- is_mutable (
Bool
): Whether the referenced data may be mutated through this. - type (
AnyType
): Type of the underlying data. - lifetime (
AnyLifetime[is_mutable.value]
): The lifetime of the reference. - address_space (
AddressSpace
): The address space of the referenced data.
Fields
- value (
!lit.ref<!kgen.paramref<:trait<@stdlib::@builtin::@anytype::@AnyType> *"type">, mut=#lit.struct.extract<:@stdlib::@builtin::@bool::@Bool is_mutable, "value">, lifetime, #lit.struct.extract<:@stdlib::@builtin::@int::@Int #lit.struct.extract<:@stdlib::@memory::@reference::@AddressSpace address_space, "_value">, "value">>
): The underlying MLIR reference.
Implemented traits
AnyType
,
CollectionElementNew
,
Copyable
,
ExplicitlyCopyable
,
Movable
,
Stringable
Methods
__init__
__init__(inout self: Self, ref [lifetime, address_space] value: type)
Constructs a Reference from a value reference.
Args:
- value (
type
): The value reference.
__init__(inout self: Self, *, other: Self)
Constructs a copy from another Reference.
Note that this does not copy the underlying data.
Args:
- other (
Self
): TheReference
to copy.
__getitem__
__getitem__(self: Self) -> ref [lifetime, address_space] type
Enable subscript syntax ref[]
to access the element.
Returns:
The MLIR reference for the Mojo compiler to use.
__eq__
__eq__(self: Self, rhs: Reference[is_mutable, type, lifetime, address_space]) -> Bool
Returns True if the two pointers are equal.
Args:
- rhs (
Reference[is_mutable, type, lifetime, address_space]
): The value of the other pointer.
Returns:
True if the two pointers are equal and False otherwise.
__ne__
__ne__(self: Self, rhs: Reference[is_mutable, type, lifetime, address_space]) -> Bool
Returns True if the two pointers are not equal.
Args:
- rhs (
Reference[is_mutable, type, lifetime, address_space]
): The value of the other pointer.
Returns:
True if the two pointers are not equal and False otherwise.
__str__
__str__(self: Self) -> String
Gets a string representation of the Reference.
Returns:
The string representation of the Reference.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
😔 What went wrong?