#![feature(plugin)] #![plugin(bounded_integer_plugin)] #[macro_use] extern crate bounded_integer; use std::ops::{Add, Sub, Mul, Div, Rem, Neg}; use bounded_integer::{BoundedInteger, Repr}; trait AssertImplBoundedInteger: BoundedInteger { } trait AssertBoundedIntegerRepr: BoundedInteger { } trait AssertImplInto: Into { } trait AssertImplAdd: Add { } trait AssertImplSub: Sub { } trait AssertImplMul: Mul { } trait AssertImplDiv: Div { } trait AssertImplRem: Rem { } trait AssertImplNeg: Neg { } bounded_integer! { #[derive(Debug)] enum A: i8 { -5...5 } } impl AssertImplBoundedInteger for A { } impl AssertBoundedIntegerRepr for A { } impl AssertImplInto for A { } impl AssertImplAdd for A { } impl<'a> AssertImplAdd<&'a A> for A { } impl<'a> AssertImplAdd for &'a A { } impl<'a, 'b> AssertImplAdd<&'a A> for &'b A { } impl AssertImplAdd for A { } impl<'a> AssertImplAdd<&'a i8> for A { } impl<'a> AssertImplAdd for &'a A { } impl<'a, 'b> AssertImplAdd<&'a i8> for &'b A { } impl AssertImplSub for A { } impl<'a> AssertImplSub<&'a A> for A { } impl<'a> AssertImplSub for &'a A { } impl<'a, 'b> AssertImplSub<&'a A> for &'b A { } impl AssertImplSub for A { } impl<'a> AssertImplSub<&'a i8> for A { } impl<'a> AssertImplSub for &'a A { } impl<'a, 'b> AssertImplSub<&'a i8> for &'b A { } impl AssertImplMul for A { } impl<'a> AssertImplMul<&'a A> for A { } impl<'a> AssertImplMul for &'a A { } impl<'a, 'b> AssertImplMul<&'a A> for &'b A { } impl AssertImplMul for A { } impl<'a> AssertImplMul<&'a i8> for A { } impl<'a> AssertImplMul for &'a A { } impl<'a, 'b> AssertImplMul<&'a i8> for &'b A { } impl AssertImplDiv for A { } impl<'a> AssertImplDiv<&'a A> for A { } impl<'a> AssertImplDiv for &'a A { } impl<'a, 'b> AssertImplDiv<&'a A> for &'b A { } impl AssertImplDiv for A { } impl<'a> AssertImplDiv<&'a i8> for A { } impl<'a> AssertImplDiv for &'a A { } impl<'a, 'b> AssertImplDiv<&'a i8> for &'b A { } impl AssertImplRem for A { } impl<'a> AssertImplRem<&'a A> for A { } impl<'a> AssertImplRem for &'a A { } impl<'a, 'b> AssertImplRem<&'a A> for &'b A { } impl AssertImplRem for A { } impl<'a> AssertImplRem<&'a i8> for A { } impl<'a> AssertImplRem for &'a A { } impl<'a, 'b> AssertImplRem<&'a i8> for &'b A { } impl AssertImplNeg for A { } impl<'a> AssertImplNeg for &'a A { } #[test] fn from_repr() { assert_eq!(Some(A::N3), A::from_repr(-3)); } #[test] fn to_repr() { assert_eq!(-3, A::N3.to_repr()); } #[test] fn min_value() { assert_eq!(A::N5, A::min_value()); } #[test] fn max_value() { assert_eq!(A::P5, A::max_value()); }