Expand description
Element-wise tuple-ization for traits.
#[auto_tuple] generates, for each requested arity, a helper trait whose
methods/consts/types forward element-wise to each element of an N-tuple:
(x, y).foo(a) desugars to (x.foo(a), y.foo(a)). See docs/design.md
for the full semantics.
use auto_tuple::auto_tuple;
#[auto_tuple]
trait Tr {
fn zero() -> usize;
}
struct X;
struct Y;
impl Tr for X { fn zero() -> usize { 1 } }
impl Tr for Y { fn zero() -> usize { 2 } }
// No import needed: the helper trait lives in this module.
assert_eq!(<(X, Y)>::zero(), (1, 2));Attribute Macrosยง
- auto_
tuple - Generates tuple helper traits for the annotated trait.