Skip to main content

BoundedCollection

Trait BoundedCollection 

Source
pub trait BoundedCollection {
    type Item;

    // Required methods
    fn with_capacity(capacity: usize) -> Self;
    fn try_push(&self, item: Self::Item) -> Result<(), Self::Item>;
    fn try_pop(&self) -> Option<Self::Item>;
    fn len(&self) -> usize;
    fn capacity(&self) -> usize;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn is_full(&self) -> bool { ... }
}
Expand description

This trait is used to describe a collection that is wrapped by a Resizable.

Fallible operations on this type may spuriously fail.

len, is_empty and is_full will never be used for synchronization.

Required Associated Types§

Source

type Item

The item stored in the collection.

Required Methods§

Source

fn with_capacity(capacity: usize) -> Self

Constructs a new instance of this type with capacity capacity.

This method is explicitly allowed to block.

Source

fn try_push(&self, item: Self::Item) -> Result<(), Self::Item>

Attempts to push an item into the collection. Returns the item as an error if the collection is full.

Source

fn try_pop(&self) -> Option<Self::Item>

Attempts to pop an item from the collection. Returns None if the collection is empty.

Source

fn len(&self) -> usize

Returns the current length of the collection. The returned value may be stale under concurrent access and should not be used for synchronization.

Source

fn capacity(&self) -> usize

Returns the total capacity of the collection.

Provided Methods§

Source

fn is_empty(&self) -> bool

Indicates whether the collection is empty. The returned value may be stale under concurrent access and should not be used for synchronization.

Source

fn is_full(&self) -> bool

Indicates whether the collection is full. The returned value may be stale under concurrent access and should not be used for synchronization.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§