ShallowClone

Derive Macro ShallowClone 

Source
#[derive(ShallowClone)]
{
    // Attributes available to this derive:
    #[index]
}
Expand description

Derives the ShallowClone trait for a struct where each field is itself a ShallowClone.

This macro generates an implementation of composable_indexes::ShallowClone for a struct by calling shallow_clone() on each field. This is useful for types that use persistent data structures where shallow cloning is more efficient than deep cloning.

§Field Attributes

  • #[index(mark_as_shallow)]: Use regular clone() instead of shallow_clone() for this field. This is useful for types that don’t implement ShallowClone.

§Example

use composable_indexes::{index, aggregation};
use composable_indexes_derive::ShallowClone;

#[derive(Clone, ShallowClone)]
struct MyIndex {
    field1: index::im::BTree<u32>,
    field2: aggregation::Count,
}