#shared #cow #gc


Shared, reference-counted, copy-on-write, single-pointer buffers

1 unstable release

0.1.0 Oct 19, 2021

#483 in Memory management


845 lines


This library proviceds shared, reference-counted string buffers with copy-on-write behavior.

For more information, check out the documentation.


This crate provides shared, reference-counted, resizable buffers with copy-on-write behavior:

These structures are meant to fill a niche not covered by other containers:

  • Unlike Vec<T> and String, they do not allocate a new buffer for every clone.
  • Unlike Rc<[T]>,Arc<[T]>, Rc<str>, and Arc<str>, they can be mutated.
  • Unlike Rc<Vec<T>>,Arc<Vec<T>>, Rc<String>, and Arc<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.

No runtime deps