#push #back #mut

push_mut

Push a value to the back of the vector, and return a mutable reference to it

1 unstable release

0.1.0 Oct 13, 2023

#2399 in Rust patterns

MIT/Apache

3KB

push_mut

Crates.io Downloads Documentation License Dependency Status

Push a value to the back of the vector, and return a mutable reference to it.

Example

use push_mut::PushMut;

fn main() {
    let mut v = Vec::with_capacity(1);
    let last = v.push_mut(1);
    assert_eq!(*last, 1);
    *last = 2;
    assert_eq!(*last, 2);   
}

No runtime deps