-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Current Implementation
Currently, the Patchable trait enforces a Clone bound on its associated Patch type:
pub trait Patchable: Sized {
/// The type of patch associated with this structure.
type Patch: Clone;
}Proposed Changes
We should remove the mandatory Clone bound to increase the library's flexibility. While Clone was useful in the original design context, it is not strictly necessary for the core logic of patching.
-
Trait Refactor
Remove the :Clonerequirement from thePatchassociated type. -
Macro Enhancements (
patchable-macro)
Update the procedural macro to allow optional derivation ofClone(TODO) and serde'sSerializeandDeserialize(DONE before this issue creation). We should introduce a new feature flag to manage this:-
Feature:
cloneable— Controls whether the generated patch type derivesClone. -
Default Features: Both
cloneableandserdeshould remain in default.
-
Rationale
Why make Clone and Serde derivations optional?
The original implementation was designed for durable computation, where checkpoints required state persistence. In that specific context:
-
Clone: We assumed patch types would always be cloneable. However, this was largely used for testing rather than core functionality. For a general-purpose library, a Patch should be able to be any type, including those that are not (or should not be) cloneable. -
Serde: Similarly, while saving state to disk and loading from disk is vital for durable computation, many other use cases do not require serialization/deserialization
By moving these into feature flags, we allow users to opt-out of these dependencies and derivations, reducing compile times and keeping the generated code lean for non-durable-computation scenarios.