File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -52,37 +52,65 @@ pub trait Integral:
52
52
+ fmt:: Debug
53
53
+ fmt:: Binary
54
54
+ fmt:: Octal
55
+ + Zero
56
+ + One
57
+ + BoundedBelow
58
+ + BoundedAbove
55
59
{
60
+ }
61
+
62
+ /// Class that has additive identity element
63
+ pub trait Zero {
64
+ /// The additive identity element
56
65
fn zero ( ) -> Self ;
66
+ }
67
+
68
+ /// Class that has multiplicative identity element
69
+ pub trait One {
70
+ /// The multiplicative identity element
57
71
fn one ( ) -> Self ;
72
+ }
73
+
74
+ pub trait BoundedBelow {
58
75
fn min_value ( ) -> Self ;
76
+ }
77
+
78
+ pub trait BoundedAbove {
59
79
fn max_value ( ) -> Self ;
60
80
}
61
81
62
82
macro_rules! impl_integral {
63
83
( $( $ty: ty) ,* ) => {
64
84
$(
65
- impl Integral for $ty {
85
+ impl Zero for $ty {
66
86
#[ inline]
67
87
fn zero( ) -> Self {
68
88
0
69
89
}
90
+ }
70
91
92
+ impl One for $ty {
71
93
#[ inline]
72
94
fn one( ) -> Self {
73
95
1
74
96
}
97
+ }
75
98
99
+ impl BoundedBelow for $ty {
76
100
#[ inline]
77
101
fn min_value( ) -> Self {
78
102
Self :: min_value( )
79
103
}
104
+ }
80
105
106
+ impl BoundedAbove for $ty {
81
107
#[ inline]
82
108
fn max_value( ) -> Self {
83
109
Self :: max_value( )
84
110
}
85
111
}
112
+
113
+ impl Integral for $ty { }
86
114
) *
87
115
} ;
88
116
}
You can’t perform that action at this time.
0 commit comments