| Crates.io | rc-vec |
| lib.rs | rc-vec |
| version | 0.1.14 |
| created_at | 2025-06-18 14:44:02.92375+00 |
| updated_at | 2025-07-11 03:41:48.676041+00 |
| description | RcVec based on Rc and can be converted from Rc without allocation |
| homepage | |
| repository | https://github.com/A4-Tacks/rc-vec-rs |
| max_upload_size | |
| id | 1717203 |
| size | 87,710 |
RcVec based on Rc and can be converted from Rc without allocation,
just like Box is converted to Vec
Due to Rc's API, this implementation cannot use realloc, resulting in some performance issues
Similar to Vec::into_boxed_slice,
RcVec::into_uniq_slice can be converted to UniqRc,
which is the packaging of Rc and behaves similarly to Box
use rc_vec::RcVec;
use std::rc::Rc;
let rc: Rc<[i32]> = Rc::new([1, 2, 3]);
let rcptr = Rc::as_ptr(&rc).cast();
let mut vec = RcVec::from(rc);
assert_eq!(vec.len(), 3);
assert_eq!(vec.capacity(), 3);
assert!(std::ptr::eq(rcptr, vec.as_ptr()));
vec.push(4);
assert_eq!(vec.len(), 4);
assert!(vec.capacity() > 3);
assert!(! std::ptr::eq(rcptr, vec.as_ptr()));
assert_eq!(vec, [1, 2, 3, 4]);
I have not checked any synchronization related issues with the Arc variant