class Array

Declaration

template <class T, size_t N>
class Array { /* full declaration omitted */ };

Description

A collection of objects of type `T`, with a fixed size `N`. An Array can not be larger than [`isize::MAX`]($sus::num::isize::MAX), as subtracting a pointer at a greater distance results in Undefined Behaviour.

Declared at: sus/collections/array.h:71

Templates

T
size_t N

Method Overview

Methods

Array<T, N>(Array<T, N>&&)

Declared at: sus/collections/array.h:126

Parameters

Array<T, N>&&

Array<T, N>(Array<T, N>&&)

Declared at: sus/collections/array.h:126

Parameters

Array<T, N>&&

Array<T, N>(Array<T, N>&&)

Declared at: sus/collections/array.h:126

Parameters

Array<T, N>&&

template <class... Ts>
constexpr Array<T, N>(Ts&&... ts) noexcept

Description

Constructs an `Array` with `N` elements from the `N` arguments given to the constructor. #[doc.overloads=ctor.values]

Declared at: sus/collections/array.h:98

Templates

Ts

Parameters

Ts&&... ts

constexpr Array<T, N>() noexcept

Declared at: sus/collections/array.h:88

inline constexpr T* as_mut_ptr() & noexcept

Description

Returns a mutable pointer to the first element in the array.

Declared at: sus/collections/array.h:261

constexpr SliceMut<T> as_mut_slice() & noexcept

Declared at: sus/collections/array.h:276

const T* as_ptr() &&

Declared at: sus/collections/array.h:258

inline constexpr const T* as_ptr() const& noexcept

Description

Returns a const pointer to the first element in the array.

Declared at: sus/collections/array.h:253

constexpr Slice<T> as_slice() const& noexcept

Declared at: sus/collections/array.h:269

constexpr Slice<T> as_slice() &&

Declared at: sus/collections/array.h:272

constexpr Array<T, N> clone() const& noexcept

Declared at: sus/collections/array.h:159

constexpr void clone_from(
    const Array<T, N>& source) & noexcept

Declared at: sus/collections/array.h:170

Parameters

const Array<T, N>& source

constexpr Option<const T&> get(
    sus::num::usize i) &&

Declared at: sus/collections/array.h:203

Parameters

sus::num::usize i

constexpr Option<const T&> get(
    sus::num::usize i) const& noexcept

Description

Returns a const reference to the element at index `i`.

Declared at: sus/collections/array.h:196

Parameters

sus::num::usize i

constexpr Option<T&> get_mut(
    sus::num::usize i) & noexcept

Description

Returns a mutable reference to the element at index `i`.

Declared at: sus/collections/array.h:206

Parameters

sus::num::usize i

inline constexpr const T& get_unchecked(
    ::sus::marker::UnsafeFnMarker,
    sus::num::usize i) const& noexcept

Description

Returns a const reference to the element at index `i`. # Safety The index `i` must be inside the bounds of the array or Undefined Behaviour results.

Declared at: sus/collections/array.h:219

Parameters

::sus::marker::UnsafeFnMarker
sus::num::usize i

inline constexpr const T& get_unchecked(
    ::sus::marker::UnsafeFnMarker,
    sus::num::usize i) &&

Declared at: sus/collections/array.h:225

Parameters

::sus::marker::UnsafeFnMarker
sus::num::usize i

inline constexpr T& get_unchecked_mut(
    ::sus::marker::UnsafeFnMarker,
    sus::num::usize i) & noexcept

Description

Returns a mutable reference to the element at index `i`. # Safety The index `i` must be inside the bounds of the array or Undefined Behaviour results.

Declared at: sus/collections/array.h:233

Parameters

::sus::marker::UnsafeFnMarker
sus::num::usize i

template <int&..., class U = T>
constexpr ArrayIntoIter<U, N>
into_iter() && noexcept

Description

Converts the array into an iterator that consumes the array and returns each element in the same order they appear in the array.

Declared at: sus/collections/array.h:314

Templates

int &
U

constexpr SliceIter<const T&> iter()
    const& noexcept

Description

Returns an iterator over all the elements in the array, visited in the same order they appear in the array. The iterator gives const access to each element.

Declared at: sus/collections/array.h:283

constexpr SliceIter<const T&> iter() &&

Declared at: sus/collections/array.h:295

constexpr SliceIterMut<T&> iter_mut() & noexcept

Description

Returns an iterator over all the elements in the array, visited in the same order they appear in the array. The iterator gives mutable access to each element.

Declared at: sus/collections/array.h:300

constexpr sus::num::usize len() const& noexcept

Description

Returns the number of elements in the array.

Declared at: sus/collections/array.h:193

template <class MapFn>
int map(MapFn f) && noexcept

Declared at: sus/collections/array.h:327

Templates

MapFn

Parameters

MapFn f

constexpr Slice<T> operator Slice<
    type - parameter - 0 - 0>() const& noexcept

Declared at: sus/collections/array.h:365

constexpr Slice<T> operator Slice<
    type - parameter - 0 - 0>() const& noexcept

Declared at: sus/collections/array.h:365

constexpr Slice<T>
operator Slice<type - parameter - 0 - 0>() &&

Declared at: sus/collections/array.h:378

constexpr Slice<T> operator Slice<
    type - parameter - 0 - 0>() & noexcept

Declared at: sus/collections/array.h:379

constexpr Slice<T> operator Slice<
    type - parameter - 0 - 0>() & noexcept

Declared at: sus/collections/array.h:379

constexpr SliceMut<T> operator SliceMut<
    type - parameter - 0 - 0>() & noexcept

Declared at: sus/collections/array.h:394

constexpr SliceMut<T> operator SliceMut<
    type - parameter - 0 - 0>() & noexcept

Declared at: sus/collections/array.h:394

template <class f : auto>
static constexpr Array<T, N> with_initializer(
    ::sus::fn::FnMut<T()> auto f) noexcept

Declared at: sus/collections/array.h:118

Templates

f:auto

Parameters

::sus::fn::FnMut<T()> auto f

template <class U>
static constexpr Array<T, N> with_value(
    const U& t) noexcept

Description

Constructs an `Array` with `N` elements from a single argument, repeatedly using it to construct each element. The given argument must be `Copy` in order to do this. To construct an Array from a single value that is `Clone` but not `Copy`, use `with_initializer([ &x ]() -> T { return sus::clone(x); })`;

Declared at: sus/collections/array.h:110

Templates

U

Parameters

const U& t

~Array<T, N>()

Declared at: sus/collections/array.h:183

~Array<T, N>()

Declared at: sus/collections/array.h:183