darling icon indicating copy to clipboard operation
darling copied to clipboard

RFE: Support negation for `Flag` (or new similar type)

Open loganmzz opened this issue 5 months ago • 1 comments

In most configuration systems, a "key" when present let's enable (or enforce) associated feature activation. It is currently supported by Flag type.

However, such systems also support disabling feature.

Example syntax:

#[my_attribute(!my_feature)]

Example (additional) API:

impl Flag {
  fn is_enabled(self) -> bool { /* ... */ }
  fn is_disabled(self) -> bool { /* ... */ }
  fn as_option(self) -> Option<bool> { /* ... */ }
}

impl From<&Flag> for Option<bool> {
    fn from(value: &Flag) -> Self {
        value.as_option()
    }
}

impl From<Option<bool>> for &Option<bool> {
    fn from(value: Option<bool>) -> Self { /* ... */}
}

loganmzz avatar Mar 07 '24 16:03 loganmzz