From 35a9bcba199f28a0d46cc6074387dd7590afa9a8 Mon Sep 17 00:00:00 2001 From: Yoan Lecoq Date: Sat, 29 Apr 2017 07:51:04 +0200 Subject: [PATCH] impl Bounded for Wrapping --- traits/src/bounds.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/traits/src/bounds.rs b/traits/src/bounds.rs index 966296c..0b8fbf4 100644 --- a/traits/src/bounds.rs +++ b/traits/src/bounds.rs @@ -1,6 +1,7 @@ use std::{usize, u8, u16, u32, u64}; use std::{isize, i8, i16, i32, i64}; use std::{f32, f64}; +use std::num::Wrapping; /// Numbers which have upper and lower bounds pub trait Bounded { @@ -35,6 +36,11 @@ bounded_impl!(i16, i16::MIN, i16::MAX); bounded_impl!(i32, i32::MIN, i32::MAX); bounded_impl!(i64, i64::MIN, i64::MAX); +impl Bounded for Wrapping { + #[inline] fn min_value() -> Self { Wrapping(T::min_value()) } + #[inline] fn max_value() -> Self { Wrapping(T::max_value()) } +} + bounded_impl!(f32, f32::MIN, f32::MAX); macro_rules! for_each_tuple_ {