#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

#2125 in Rust patterns

Download history 10/week @ 2024-02-20 40/week @ 2024-02-27 1/week @ 2024-03-05 82/week @ 2024-03-12 5/week @ 2024-03-19 39/week @ 2024-03-26 66/week @ 2024-04-02 64/week @ 2024-04-09 61/week @ 2024-04-16 25/week @ 2024-04-23 22/week @ 2024-04-30 86/week @ 2024-05-07 360/week @ 2024-05-14 29/week @ 2024-05-21 1/week @ 2024-06-04

397 downloads per month

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