I would like to write a trait that requires overriding exactly one of its functions. Overriding zero or more than one fns should be a compile error.
impl OnChange<const KEY: &'static str> {
fn on_change(raw: &str);
/// basically does `self.on_change(|raw| f(parse_bool(raw)))`
fn on_bool_change(val: bool);
/// same for bool
fn on_u64_change(val: u64);
}
Also happy to consider other approaches. I am also considering:
- Split it out into 3 different traits
OnChangeOnChangeBool,OnChangeU64 - Add a generic
OnChange<const KEY: &'static str, const kind: ValueKind>