Struct Subspace :: sus :: collections :: Drain

template <class ItemT>
struct Drain final
{ ... };

A draining iterator for Vec<T>.

This struct is created by Vec::drain. See its documentation for more.


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 in order to be move-constructed, it will panic on move-assignment.


sus::iter::ExactSizeIterator trait.

auto keep_rest() && -> void

Keep unyielded elements in the source Vec.

auto next() -> Option<sus::collections::Drain::Item>
auto next_back() -> Option<sus::collections::Drain::Item>
auto size_hint() const -> SizeHint


auto operator=(Drain<ItemT>&&) -> Drain<ItemT>&

Drain may be move-constructed in order to be stored as a member of other objects, but it can not be assigned-to. See the class documentation for more.


Calling this function will always panic.