Is there a way to get warnings or errors if I try to #[derive(Clone)] on a struct/enum where it would take longer than O(1) ?
The concrete case is that I am building some complicated structs, and I am afraid that I have a #[derive(Clone)] on something where it has a field that is Vec<> instead of Rc<Vec<_>> -- and then, not realizing that the clone is O(1), over use it.
Thus, I am looking for something that can warn me on #[derive(Clone)] that are not obviously O(1).
You could create a CheapClone trait, implement it for various standard types (like primitives, references, Rc, and Arc), and then create a #[derive(CheapClone)] macro for custom types that relies on all the fields implementing CheapClone.