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§
Required Methods§
Sourcefn with_capacity(capacity: usize) -> Self
fn with_capacity(capacity: usize) -> Self
Constructs a new instance of this type with capacity capacity.
This method is explicitly allowed to block.
Sourcefn try_push(&self, item: Self::Item) -> Result<(), Self::Item>
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.
Sourcefn try_pop(&self) -> Option<Self::Item>
fn try_pop(&self) -> Option<Self::Item>
Attempts to pop an item from the collection.
Returns None if the collection is empty.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".