lazy_cogs/lazy.rs
1/// Trait for creating data that can be lazily cloned.
2///
3/// This provides both an interface for lazy cloning when the data is known to not be mutated.
4/// And an eager clone for data that is likely to be mutated.
5pub trait LazyClone {
6 /// The O(1) lazy-clone method.
7 /// Useful for cloning data that doesn't necessarily need to be mutated.
8 fn lazy(&self) -> Self;
9
10 /// A non-lazy cloning method. Useful for cloning data that is known to modified
11 fn eager(&self) -> Self;
12
13 /// Checks if the structure can be mutated with no side effects
14 fn is_mutable(&self) -> bool;
15}