Skip to main content

Contract

Trait Contract 

Source
pub trait Contract {
    // Required method
    fn contract(&mut self, count: usize);
}
Expand description

Opposite of Extend.

Required Methods§

Source

fn contract(&mut self, count: usize)

Contracts the collection, removing the given number of items from its end.

§Overflow Behavior

This method may panic if count is larger than the size of the collection. Since this check may incur performance penalities, it is only guaranteed if debug assertions are enabled.

In these cases, the collection must still correctly remove the elements, but may decide to not notify the user that less than the count of items were removed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Contract for String

Available on crate feature alloc only.

Pops some number of characters off the end of the string.

Source§

fn contract(&mut self, count: usize)

Source§

impl<T> Contract for LinkedList<T>

Available on crate feature alloc only.

Pops items off the back of the LinkedList.

Source§

fn contract(&mut self, count: usize)

Source§

impl<T> Contract for Vec<T>

Available on crate feature alloc only.

Pops items off the Vec.

Source§

fn contract(&mut self, count: usize)

Source§

impl<T> Contract for VecDeque<T>

Available on crate feature alloc only.

Pops items off the back of the VecDeque.

Source§

fn contract(&mut self, count: usize)

Implementors§