Crates.io | push_mut |
lib.rs | push_mut |
version | 0.1.0 |
source | src |
created_at | 2023-10-13 19:25:39.71427 |
updated_at | 2023-10-13 19:25:39.71427 |
description | Push a value to the back of the vector, and return a mutable reference to it. |
homepage | |
repository | https://github.com/JohnScience/push_mut |
max_upload_size | |
id | 1002578 |
size | 2,736 |
Push a value to the back of the vector, and return a mutable reference to it.
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);
}