| Crates.io | temporary-annex |
| lib.rs | temporary-annex |
| version | 0.1.0 |
| created_at | 2022-01-11 18:30:05.428868+00 |
| updated_at | 2022-01-11 18:30:05.428868+00 |
| description | Helper for creating temporary annex on a collection |
| homepage | |
| repository | https://github.com/kaleidawave/temporary-annex |
| max_upload_size | |
| id | 512390 |
| size | 5,466 |
Allows pushing to a Vec (or any other type implementing Annexable) with cleanup once result goes out of scope.
e.g.
let mut vec1 = vec![1, 2, 3];
assert_eq!(vec1, [1, 2, 3]);
{
let new_vec_ref = vec1.push_annex(4);
assert_eq!(*new_vec_ref, [1, 2, 3, 4]);
}
assert_eq!(vec1, [1, 2, 3]);
This has the effect of a immutable structure but uses the same underlying allocation (no cloning or additional allocations).