pub trait Queue<T> {
// Required methods
fn has_elements(&self) -> bool;
fn is_full(&self) -> bool;
fn len(&self) -> usize;
fn enqueue(&mut self, val: T) -> bool;
fn push(&mut self, val: T) -> Option<T>;
fn dequeue(&mut self) -> Option<T>;
fn remove_first_matching<F>(&mut self, f: F) -> Option<T>
where F: Fn(&T) -> bool;
fn empty(&mut self);
fn retain<F>(&mut self, f: F)
where F: FnMut(&T) -> bool;
}
Required Methods§
Sourcefn has_elements(&self) -> bool
fn has_elements(&self) -> bool
Returns true if there are any items in the queue, false otherwise.
Sourcefn enqueue(&mut self, val: T) -> bool
fn enqueue(&mut self, val: T) -> bool
If the queue isn’t full, add a new element to the back of the queue. Returns whether the element was added.
Sourcefn push(&mut self, val: T) -> Option<T>
fn push(&mut self, val: T) -> Option<T>
Add a new element to the back of the queue, poping one from the front if necessary.
Sourcefn remove_first_matching<F>(&mut self, f: F) -> Option<T>
fn remove_first_matching<F>(&mut self, f: F) -> Option<T>
Remove and return one (the first) element that matches the predicate.
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.