Trait Growable

Source
pub trait Growable<Item>:
    Collection<Item>
    + FromIterator<Item>
    + Extend<Item>
    + Default { }
Expand description

A growable collection supporting construction, incremental accumulation, and empty initialization.

This trait extends Collection with construction and mutation capabilities, enabling values to be built and appended over time.

§Capabilities:

  • FromIterator: Allows constructing the collection from iterator output.
  • Extend: Supports incremental addition of elements from an iterator.
  • Default: Provides a canonical empty instance for initialization.

§Design Notes:

  • Represents dynamic, resizable collections.
  • Excludes fixed-size containers that cannot grow or be constructed generically.
  • Separates construction and mutation semantics from traversal and indexing.

§Supported Types:

  • Vec<T>
  • VecDeque<T>
  • BTreeSet<T>

§Usage:

Use this trait when:

  • collections must be constructed from iterators,
  • elements are appended dynamically,
  • mutation is part of the execution logic.

For iteration and indexing without mutation, see Collection.

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.

Implementors§

Source§

impl<T, Item> Growable<Item> for T
where T: Collection<Item> + FromIterator<Item> + Extend<Item> + Default,