Macro impl_not_auto_value

Source
macro_rules! impl_not_auto_value {
    ($ty:ty) => { ... };
}
Expand description

A macro that implements NotAutoValue for your type.

This macro generates:

  • a NotAutoValue impl for ty
  • a test module with a test that ensures “auto” cannot be deserialized as ty

§Example

#[derive(Serialize, Deserialize)]
struct Foo;

impl_not_auto_value!(Foo);

#[derive(Serialize, Deserialize)]
struct Bar;

fn main() {
   let _foo: ExplicitOrAuto<Foo> = ExplicitOrAuto::Auto;

   // Using a type that does not implement NotAutoValue is an error:
   // let _bar: ExplicitOrAuto<Bar> = ExplicitOrAuto::Auto;
}