struct Drain

Declaration

template <class ItemT>
struct Drain { /* full declaration omitted */ };

Description

A draining iterator for `Vec <T >`. This struct is created by Vec::drain. See its documentation for more. # Panics Drain can not support move-assignment because it holds a reference to a Vec from which it was created. Assigning can change the Vec to which it is pointing, but that Vec may have been created _after_ the Drain object, since it was not created from that Vec. Then on destruction, Drain will point to a destroyed Vec: ``` auto v1 = Vec <i32 >(1); auto d1 = v1.drain(); // Points at v1. auto v2 = Vec <i32 >(1); auto d2 = v2.drain(); // Points at v2. d1 = sus::move(d2); // Points at v2, is destroyed after v2. ``` While Drain is satisfies [`Move`]($sus::mem::Move) in order to be move-constructed, it will panic on move-assignment.

Declared at: sus/collections/iterators/drain.h:53

Templates

ItemT

Method Overview

  • public constexpr Drain<ItemT>(Drain<ItemT> && rhs) noexcept
  • public constexpr Drain<ItemT>(Vec<sus::collections::Drain::Item> && vec, int range) noexcept
  • public ::sus::num::usize exact_size_hint() const noexcept
  • public void keep_rest() && noexcept
  • public Option<sus::collections::Drain::Item> next() noexcept
  • public Option<sus::collections::Drain::Item> next_back() noexcept
  • public ::sus::iter::SizeHint size_hint() const noexcept
  • public ~Drain<ItemT>() noexcept

Methods

constexpr Drain<ItemT>(
    Drain<ItemT>&& rhs) noexcept

Declared at: sus/collections/iterators/drain.h:59

Parameters

Drain<ItemT>&& rhs

constexpr Drain<ItemT>(
    Vec<sus::collections::Drain::Item>&& vec,
    int range) noexcept

Declared at: sus/collections/iterators/drain.h:179

Parameters

Vec<sus::collections::Drain::Item>&& vec
int range

::sus::num::usize exact_size_hint() const noexcept

Description

sus::iter::ExactSizeIterator trait.

Declared at: sus/collections/iterators/drain.h:139

void keep_rest() && noexcept

Description

Keep unyielded elements in the source `Vec`.

Declared at: sus/collections/iterators/drain.h:89

Option<sus::collections::Drain::Item>
next() noexcept

Declared at: sus/collections/iterators/drain.h:120

Option<sus::collections::Drain::Item>
next_back() noexcept

Declared at: sus/collections/iterators/drain.h:127

::sus::iter::SizeHint size_hint() const noexcept

Declared at: sus/collections/iterators/drain.h:134

~Drain<ItemT>() noexcept

Declared at: sus/collections/iterators/drain.h:79