Module rust_examples::rc[][src]

Expand description

This module presents various kinds of pointers and their behaviour under Clone.

The example covered in tests demonstrates the comparison between

  1. Shared references that can be simply cloned (shallow copied)
  2. Box pointer to heap data that, because they are owned, delegate cloning to the owned instance (i.e. are potentially deep copied)
  3. Rc smart pointer which implements Clone by imcrementing reference counter and returning a cheap copy of itself with the same data reference (i.e. shallow copy at the cost of an additional counter)

Structs

Container for Data allocated and owned in various ways.

Thin wrapper around usize serving as an internal counter for the number of clones