Crate rc_collections

Source
Expand description

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.

Structsยง

  • A thread-safe, shared, reference-counted string buffer with copy-on-write behavior
  • A shared, reference-counted string buffer with copy-on-write behavior
  • A shared, reference-counted resizable buffer with copy-on-write behavior