MatchableDerive

Derive Macro MatchableDerive 

Source
#[derive(MatchableDerive)]
Expand description

Derive macro for implementing the Matchable trait.

This macro automatically implements the get_field method for structs, allowing field-based condition matching.

§Example

#[derive(Matchable, PartialEq)]
struct Product {
    id: i32,
    name: String,
    price: f64,
    in_stock: bool,
    description: Option<String>,
}

The macro generates:

  • get_field(&self, field: &str) -> Option<&dyn Any> - Returns a reference to any field by name
  • Handles Option<T> fields by unwrapping them when present