@@ -22,7 +22,7 @@ static LEVEL_REGEX: LazyLock<Regex> = LazyLock::new(|| {
2222
2323/// Error variants which can be encountered when creating a new [`Level`] from
2424/// unparsed input.
25- #[ derive( Debug , PartialEq , Snafu ) ]
25+ #[ derive( Debug , PartialEq , Eq , Snafu ) ]
2626pub enum ParseLevelError {
2727 #[ snafu( display( "invalid level format, expected alpha<VERSION>|beta<VERSION>" ) ) ]
2828 InvalidFormat ,
@@ -87,13 +87,13 @@ impl PartialOrd for Level {
8787impl Ord for Level {
8888 fn cmp ( & self , other : & Self ) -> Ordering {
8989 match self {
90- Level :: Alpha ( lhs) => match other {
91- Level :: Alpha ( rhs) => lhs. cmp ( rhs) ,
92- Level :: Beta ( _) => Ordering :: Less ,
90+ Self :: Alpha ( lhs) => match other {
91+ Self :: Alpha ( rhs) => lhs. cmp ( rhs) ,
92+ Self :: Beta ( _) => Ordering :: Less ,
9393 } ,
94- Level :: Beta ( lhs) => match other {
95- Level :: Alpha ( _) => Ordering :: Greater ,
96- Level :: Beta ( rhs) => lhs. cmp ( rhs) ,
94+ Self :: Beta ( lhs) => match other {
95+ Self :: Alpha ( _) => Ordering :: Greater ,
96+ Self :: Beta ( rhs) => lhs. cmp ( rhs) ,
9797 } ,
9898 }
9999 }
@@ -103,12 +103,12 @@ impl<T> Add<T> for Level
103103where
104104 T : Into < u64 > ,
105105{
106- type Output = Level ;
106+ type Output = Self ;
107107
108108 fn add ( self , rhs : T ) -> Self :: Output {
109109 match self {
110- Level :: Alpha ( lhs) => Level :: Alpha ( lhs + rhs. into ( ) ) ,
111- Level :: Beta ( lhs) => Level :: Beta ( lhs + rhs. into ( ) ) ,
110+ Self :: Alpha ( lhs) => Self :: Alpha ( lhs + rhs. into ( ) ) ,
111+ Self :: Beta ( lhs) => Self :: Beta ( lhs + rhs. into ( ) ) ,
112112 }
113113 }
114114}
@@ -119,8 +119,7 @@ where
119119{
120120 fn add_assign ( & mut self , rhs : T ) {
121121 match self {
122- Level :: Alpha ( lhs) => * lhs + rhs. into ( ) ,
123- Level :: Beta ( lhs) => * lhs + rhs. into ( ) ,
122+ Self :: Alpha ( lhs) | Self :: Beta ( lhs) => * lhs + rhs. into ( ) ,
124123 } ;
125124 }
126125}
@@ -129,12 +128,12 @@ impl<T> Sub<T> for Level
129128where
130129 T : Into < u64 > ,
131130{
132- type Output = Level ;
131+ type Output = Self ;
133132
134133 fn sub ( self , rhs : T ) -> Self :: Output {
135134 match self {
136- Level :: Alpha ( lhs) => Level :: Alpha ( lhs - rhs. into ( ) ) ,
137- Level :: Beta ( lhs) => Level :: Beta ( lhs - rhs. into ( ) ) ,
135+ Self :: Alpha ( lhs) => Self :: Alpha ( lhs - rhs. into ( ) ) ,
136+ Self :: Beta ( lhs) => Self :: Beta ( lhs - rhs. into ( ) ) ,
138137 }
139138 }
140139}
@@ -145,17 +144,16 @@ where
145144{
146145 fn sub_assign ( & mut self , rhs : T ) {
147146 match self {
148- Level :: Alpha ( lhs) => * lhs - rhs. into ( ) ,
149- Level :: Beta ( lhs) => * lhs - rhs. into ( ) ,
147+ Self :: Alpha ( lhs) | Self :: Beta ( lhs) => * lhs - rhs. into ( ) ,
150148 } ;
151149 }
152150}
153151
154152impl Display for Level {
155153 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
156154 match self {
157- Level :: Alpha ( alpha) => write ! ( f, "alpha{}" , alpha ) ,
158- Level :: Beta ( beta) => write ! ( f, "beta{}" , beta ) ,
155+ Self :: Alpha ( alpha) => write ! ( f, "alpha{alpha}" ) ,
156+ Self :: Beta ( beta) => write ! ( f, "beta{beta}" ) ,
159157 }
160158 }
161159}
@@ -181,11 +179,11 @@ mod test {
181179
182180 #[ apply( ord_cases) ]
183181 fn ord ( input : Level , other : Level , expected : Ordering ) {
184- assert_eq ! ( input. cmp( & other) , expected)
182+ assert_eq ! ( input. cmp( & other) , expected) ;
185183 }
186184
187185 #[ apply( ord_cases) ]
188186 fn partial_ord ( input : Level , other : Level , expected : Ordering ) {
189- assert_eq ! ( input. partial_cmp( & other) , Some ( expected) )
187+ assert_eq ! ( input. partial_cmp( & other) , Some ( expected) ) ;
190188 }
191189}
0 commit comments