Macro multi_eq_make_trait

Source
macro_rules! multi_eq_make_trait {
    ($vis:vis, $trait_name:ident, $method_name:ident) => { ... };
    ($trait_name:ident, $method_name:ident) => { ... };
}
Expand description

Macro to define a comparison trait

The format of the generated trait is the same as PartialEq, but with potentially different names.

§Parameters:

  • vis - optional visibility specifier
  • trait_name - name of the trait being defined
  • method_name - name of the method in the trait

§Example:

use multi_eq::*;

multi_eq_make_trait!(pub, PublicCustomEq, custom_eq);
multi_eq_make_trait!(PrivateCustomEq, eq);

§Generated code:

pub trait PublicCustomEq {
    fn custom_eq(&self, other: &Self) -> bool;
}

trait PrivateCustomEq {
    fn eq(&self, other: &Self) -> bool;
}