Macro zero_sum::prepare_evaluation_tuple [] [src]

macro_rules! prepare_evaluation_tuple {
    ($type_: ident) => { ... };
}

Implement arithmetic operators (Add, Sub, Mul, Neg, Div) and Display for a tuple struct in terms of the enclosed type.

Example

#[macro_use]
extern crate zero_sum;
use std::i32;
use std::ops::{Add, Div, Mul, Neg, Sub};

#[derive(Clone, Copy, PartialEq, PartialOrd)]
struct Eval(i32);

prepare_evaluation_tuple!(Eval); // impl Add, Div, Mul, Neg, Sub, and Display

impl Evaluation for Eval {
    fn null() -> Eval { Eval(0) }
    fn shift(self, steps: i32) -> Eval { Eval(self.0 + steps) }
    fn win() -> Eval { Eval(100000) }
    fn max() -> Eval { Eval(i32::MAX) }
    fn is_win(&self) -> bool { self.0.abs() > 99000 }
}