@@ -44,7 +44,7 @@ use std::str::FromStr;
44
44
#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
45
45
pub struct StatusCode ( NonZeroU16 ) ;
46
46
47
- /// A possible error value when converting a `StatusCode` from a `u16` or `&str`
47
+ /// A possible error value when converting a `StatusCode` from a `u16` or `&str`.
48
48
///
49
49
/// This error indicates that the supplied input was not a valid number, was less
50
50
/// than 100, or was greater than 999.
@@ -80,7 +80,7 @@ impl StatusCode {
80
80
. ok_or_else ( InvalidStatusCode :: new)
81
81
}
82
82
83
- /// Converts a &[u8] to a status code
83
+ /// Converts a ` &[u8]` to a status code.
84
84
pub fn from_bytes ( src : & [ u8 ] ) -> Result < StatusCode , InvalidStatusCode > {
85
85
if src. len ( ) != 3 {
86
86
return Err ( InvalidStatusCode :: new ( ) ) ;
@@ -117,7 +117,7 @@ impl StatusCode {
117
117
/// ```
118
118
#[ inline]
119
119
pub const fn as_u16 ( & self ) -> u16 {
120
- ( * self ) . 0 . get ( )
120
+ self . 0 . get ( )
121
121
}
122
122
123
123
/// Returns a &str representation of the `StatusCode`
@@ -175,31 +175,31 @@ impl StatusCode {
175
175
/// Check if status is within 100-199.
176
176
#[ inline]
177
177
pub fn is_informational ( & self ) -> bool {
178
- 200 > self . 0 . get ( ) && self . 0 . get ( ) >= 100
178
+ ( 100 .. 200 ) . contains ( & self . 0 . get ( ) )
179
179
}
180
180
181
181
/// Check if status is within 200-299.
182
182
#[ inline]
183
183
pub fn is_success ( & self ) -> bool {
184
- 300 > self . 0 . get ( ) && self . 0 . get ( ) >= 200
184
+ ( 200 .. 300 ) . contains ( & self . 0 . get ( ) )
185
185
}
186
186
187
187
/// Check if status is within 300-399.
188
188
#[ inline]
189
189
pub fn is_redirection ( & self ) -> bool {
190
- 400 > self . 0 . get ( ) && self . 0 . get ( ) >= 300
190
+ ( 300 .. 400 ) . contains ( & self . 0 . get ( ) )
191
191
}
192
192
193
193
/// Check if status is within 400-499.
194
194
#[ inline]
195
195
pub fn is_client_error ( & self ) -> bool {
196
- 500 > self . 0 . get ( ) && self . 0 . get ( ) >= 400
196
+ ( 400 .. 500 ) . contains ( & self . 0 . get ( ) )
197
197
}
198
198
199
199
/// Check if status is within 500-599.
200
200
#[ inline]
201
201
pub fn is_server_error ( & self ) -> bool {
202
- 600 > self . 0 . get ( ) && self . 0 . get ( ) >= 500
202
+ ( 500 .. 600 ) . contains ( & self . 0 . get ( ) )
203
203
}
204
204
}
205
205
0 commit comments