1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
//! Note: this crate realy wants `const fn`s in traits. use std::ops::*; mod helpers; /// Anything that behaves like a number pub trait Num: Copy + num_traits::NumAssign + std::cmp::Ord{} #[derive(Clone, Copy)] pub struct Range<T: Num> { min: T, max: T, } // The goal is to uncoment these lines and have it work // We cant impl Num because Num Needs Ord for comparisons to see which args // will be min and max. However we cant impl ord for range because overlaping // ranges are unclear //impl<T: Num> num_traits::NumAssign for Range<T>{ // //} #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } }