Trait Container

Source
pub trait Container:
    Borrow
    + Clear
    + for<'a> Push<Self::Ref<'a>>
    + Default
    + Send {
    // Required method
    fn reserve_for<'a, I>(&mut self, selves: I)
       where Self: 'a,
             I: Iterator<Item = Self::Borrowed<'a>> + Clone;

    // Provided methods
    fn with_capacity_for<'a, I>(selves: I) -> Self
       where Self: 'a,
             I: Iterator<Item = Self::Borrowed<'a>> + Clone { ... }
    fn extend_from_self(
        &mut self,
        other: Self::Borrowed<'_>,
        range: Range<usize>,
    ) { ... }
}
Expand description

A container that can hold C, and provide its preferred references through Borrow.

As an example, (Vec<A>, Vecs<Vec<B>>).

Required Methods§

Source

fn reserve_for<'a, I>(&mut self, selves: I)
where Self: 'a, I: Iterator<Item = Self::Borrowed<'a>> + Clone,

Provided Methods§

Source

fn with_capacity_for<'a, I>(selves: I) -> Self
where Self: 'a, I: Iterator<Item = Self::Borrowed<'a>> + Clone,

Allocates an empty container that can be extended by selves without reallocation.

This goal is optimistic, and some containers may struggle to size correctly, especially if they employ compression or other variable-sizing techniques that respond to the data and the order in which is it presented. Best effort, but still useful!

Source

fn extend_from_self(&mut self, other: Self::Borrowed<'_>, range: Range<usize>)

Extends self by a range in other.

This method has a default implementation, but can and should be specialized when ranges can be copied. As an example, lists of lists are often backed by contiguous elements, all of which can be memcopied, with only the offsets into them (the bounds) to push either before or after (rather than during).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<AA: Container> Container for (AA,)

Source§

fn extend_from_self(&mut self, other: Self::Borrowed<'_>, range: Range<usize>)

Source§

fn reserve_for<'a, I>(&mut self, selves: I)
where Self: 'a, I: Iterator<Item = Self::Borrowed<'a>> + Clone,

Source§

impl<AA: Container, BB: Container> Container for (AA, BB)

Source§

fn extend_from_self(&mut self, other: Self::Borrowed<'_>, range: Range<usize>)

Source§

fn reserve_for<'a, I>(&mut self, selves: I)
where Self: 'a, I: Iterator<Item = Self::Borrowed<'a>> + Clone,

Source§

impl<AA: Container, BB: Container, CC: Container> Container for (AA, BB, CC)

Source§

fn extend_from_self(&mut self, other: Self::Borrowed<'_>, range: Range<usize>)

Source§

fn reserve_for<'a, I>(&mut self, selves: I)
where Self: 'a, I: Iterator<Item = Self::Borrowed<'a>> + Clone,

Source§

impl<AA: Container, BB: Container, CC: Container, DD: Container> Container for (AA, BB, CC, DD)

Source§

fn extend_from_self(&mut self, other: Self::Borrowed<'_>, range: Range<usize>)

Source§

fn reserve_for<'a, I>(&mut self, selves: I)
where Self: 'a, I: Iterator<Item = Self::Borrowed<'a>> + Clone,

Source§

impl<AA: Container, BB: Container, CC: Container, DD: Container, EE: Container> Container for (AA, BB, CC, DD, EE)

Source§

fn extend_from_self(&mut self, other: Self::Borrowed<'_>, range: Range<usize>)

Source§

fn reserve_for<'a, I>(&mut self, selves: I)
where Self: 'a, I: Iterator<Item = Self::Borrowed<'a>> + Clone,

Source§

impl<AA: Container, BB: Container, CC: Container, DD: Container, EE: Container, FF: Container> Container for (AA, BB, CC, DD, EE, FF)

Source§

fn extend_from_self(&mut self, other: Self::Borrowed<'_>, range: Range<usize>)

Source§

fn reserve_for<'a, I>(&mut self, selves: I)
where Self: 'a, I: Iterator<Item = Self::Borrowed<'a>> + Clone,

Source§

impl<AA: Container, BB: Container, CC: Container, DD: Container, EE: Container, FF: Container, GG: Container> Container for (AA, BB, CC, DD, EE, FF, GG)

Source§

fn extend_from_self(&mut self, other: Self::Borrowed<'_>, range: Range<usize>)

Source§

fn reserve_for<'a, I>(&mut self, selves: I)
where Self: 'a, I: Iterator<Item = Self::Borrowed<'a>> + Clone,

Source§

impl<AA: Container, BB: Container, CC: Container, DD: Container, EE: Container, FF: Container, GG: Container, HH: Container> Container for (AA, BB, CC, DD, EE, FF, GG, HH)

Source§

fn extend_from_self(&mut self, other: Self::Borrowed<'_>, range: Range<usize>)

Source§

fn reserve_for<'a, I>(&mut self, selves: I)
where Self: 'a, I: Iterator<Item = Self::Borrowed<'a>> + Clone,

Source§

impl<AA: Container, BB: Container, CC: Container, DD: Container, EE: Container, FF: Container, GG: Container, HH: Container, II: Container> Container for (AA, BB, CC, DD, EE, FF, GG, HH, II)

Source§

fn extend_from_self(&mut self, other: Self::Borrowed<'_>, range: Range<usize>)

Source§

fn reserve_for<'a, I>(&mut self, selves: I)
where Self: 'a, I: Iterator<Item = Self::Borrowed<'a>> + Clone,

Source§

impl<AA: Container, BB: Container, CC: Container, DD: Container, EE: Container, FF: Container, GG: Container, HH: Container, II: Container, JJ: Container> Container for (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ)

Source§

fn extend_from_self(&mut self, other: Self::Borrowed<'_>, range: Range<usize>)

Source§

fn reserve_for<'a, I>(&mut self, selves: I)
where Self: 'a, I: Iterator<Item = Self::Borrowed<'a>> + Clone,

Source§

impl<T: Clone + Send + 'static> Container for Vec<T>

Source§

fn extend_from_self(&mut self, other: Self::Borrowed<'_>, range: Range<usize>)

Source§

fn reserve_for<'a, I>(&mut self, selves: I)
where Self: 'a, I: Iterator<Item = Self::Borrowed<'a>> + Clone,

Implementors§