Crate rc_collections[−][src]
Expand description
This crate provides shared, reference-counted, resizable buffers with copy-on-write behavior:
RcVec<T>
is analogous toRc<Vec<T>>
RcString
is analogous toRc<String>
ArcString
is analogous toArc<String>
These structures are meant to fill a niche not covered by other containers:
- Unlike
Vec<T>
andString
, they do not allocate a new buffer for every clone. - Unlike
Rc<[T]>
,Arc<[T]>
,Rc<str>
, andArc<str>
, they can be mutated. - Unlike
Rc<Vec<T>>
,Arc<Vec<T>>
,Rc<String>
, andArc<String>
, they only contain a single level of pointer indirection.
Mutability is enabled by copying the underlying buffer on mutable operations if there is more than 1 reference to it. If there is not enough capacity for push operations, the buffer is reallocated with a larger capacity. If there is only 1 reference, the buffer is then mutated in place.