Skip to main content

clone_behavior/
speed.rs

1mod sealed {
2    #[expect(unnameable_types, reason = "This is intentional, and creates a sealed trait")]
3    pub trait Sealed {}
4}
5
6
7use self::sealed::Sealed;
8
9
10/// Indicates that a cloning operation is constant-time.
11///
12/// This might be nearly instant, or involve briefly acquiring a lock and performing a few
13/// computations.
14#[derive(Debug, Clone, Copy)]
15pub enum Fast {}
16/// Places no constraints on the speed of a cloning operation.
17#[derive(Debug, Clone, Copy)]
18pub enum MaybeSlow {}
19
20
21impl Sealed for Fast {}
22impl Sealed for MaybeSlow {}
23
24
25/// Trait for indicating the overhead and/or time complexity of a cloning operation.
26pub trait Speed: Sealed {}
27
28impl Speed for Fast {}
29impl Speed for MaybeSlow {}