generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 142
Closed
Labels
[C] Feature / EnhancementA new feature request or enhancement to an existing feature.A new feature request or enhancement to an existing feature.[E] User ExperienceAn UX enhancement for an existing feature. Including deprecation of an existing one.An UX enhancement for an existing feature. Including deprecation of an existing one.
Description
Requested feature: Create a proc_macro that allows users to annotate their structs and enums with #[derive(Invariant)]
Use case: Allow users to easily generate implementation of the Invariant types for their custom structs and enums whenever the invariant of their types is the combination of their field's invariant.
Link to relevant documentation (Rust reference, Nomicon, RFC):
Is this a breaking change? No
Test case:
#[derive(Invariant)]
enum Operation {
Sum,
Sub,
}
fn main() {
let op : Operation = rmc::any();
let v1 : i32 = rmc::any();
let v2: i32 = rmc::any();
calculate(v1, v2, op);
}This should generate something like:
unsafe impl Invariant for Operation {
fn is_valid(&self) -> bool {
matches!(*self, Operation::Sum | Operation::Sub);
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
[C] Feature / EnhancementA new feature request or enhancement to an existing feature.A new feature request or enhancement to an existing feature.[E] User ExperienceAn UX enhancement for an existing feature. Including deprecation of an existing one.An UX enhancement for an existing feature. Including deprecation of an existing one.