Skip to main content

struct

Tuple

The type of a literal tuple expression.

A tuple consists of zero or more values, separated by commas.

Parameters

  • *element_types (CollectionElement): The elements type.

Fields

  • storage (!kgen.pack<:variadic<trait<@stdlib::@builtin::@value::@CollectionElement>> element_types>): The underlying storage for the tuple.

Implemented traits

AnyType, CollectionElement, Copyable, Movable, Sized

Methods

__init__

__init__(inout self: Self, /, *args: *element_types)

Construct the tuple.

Args:

  • *args (*element_types): Initial values.

__init__(inout self: Self, /, *, storage: VariadicPack[elt_is_mutable, lifetime, CollectionElement, element_types])

Construct the tuple from a low-level internal representation.

Args:

  • storage (VariadicPack[elt_is_mutable, lifetime, CollectionElement, element_types]): The variadic pack storage to construct from.

__copyinit__

__copyinit__(inout self: Self, /, existing: Self)

Copy construct the tuple.

Args:

  • existing (Self): The value to copy from.

__moveinit__

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

Move construct the tuple.

Args:

  • existing (Self): The value to move from.

__del__

__del__(owned self: Self)

Destructor that destroys all of the elements.

__len__

static __len__() -> Int

Return the number of elements in the tuple.

Returns:

The tuple length.

__len__(self: Self) -> Int

Get the number of elements in the tuple.

Returns:

The tuple length.

__refitem__

__refitem__[idx: Int, mutability: i1, self_life: lifetime<*(0,1)>](self_lit: !lit.ref<_stdlib::_builtin::_tuple::_Tuple<:variadic<trait<_stdlib::_builtin::_value::_CollectionElement>> element_types>, mut=mutability, self_life>) -> Reference[element_types[$0.value], $1, $2, 0]

get

get[i: Int, T: CollectionElement](self: Self) -> $1

Get a tuple element and rebind to the specified type.

Parameters:

  • i (Int): The element index.
  • T (CollectionElement): The element type.

Returns:

The tuple element at the requested index.