File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ impl fmt::Display for RawStatus {
8282
8383impl From < StatusCode > for RawStatus {
8484 fn from ( status : StatusCode ) -> RawStatus {
85- RawStatus ( status. to_u16 ( ) , Cow :: Borrowed ( status. canonical_reason ( ) . unwrap_or ( "" ) ) )
85+ RawStatus ( status. into ( ) , Cow :: Borrowed ( status. canonical_reason ( ) . unwrap_or ( "" ) ) )
8686 }
8787}
8888
Original file line number Diff line number Diff line change 22use std:: fmt;
33use std:: cmp:: Ordering ;
44
5- // shamelessly lifted from Teepee. I tried a few schemes, this really
6- // does seem like the best. Improved scheme to support arbitrary status codes.
7-
85/// An HTTP status code (`status-code` in RFC 7230 et al.).
96///
107/// This enum contains all common status codes and an Unregistered
@@ -230,6 +227,7 @@ pub enum StatusCode {
230227impl StatusCode {
231228
232229 #[ doc( hidden) ]
230+ // Not part of public API or API contract. Could disappear.
233231 pub fn from_u16 ( n : u16 ) -> StatusCode {
234232 match n {
235233 100 => StatusCode :: Continue ,
@@ -296,8 +294,7 @@ impl StatusCode {
296294 }
297295 }
298296
299- #[ doc( hidden) ]
300- pub fn to_u16 ( & self ) -> u16 {
297+ fn to_u16 ( & self ) -> u16 {
301298 match * self {
302299 StatusCode :: Continue => 100 ,
303300 StatusCode :: SwitchingProtocols => 101 ,
@@ -553,6 +550,12 @@ impl Default for StatusCode {
553550 }
554551}
555552
553+ impl Into < u16 > for StatusCode {
554+ fn into ( self ) -> u16 {
555+ self . to_u16 ( )
556+ }
557+ }
558+
556559/// The class of an HTTP `status-code`.
557560///
558561/// [RFC 7231, section 6 (Response Status Codes)](https://tools.ietf.org/html/rfc7231#section-6):
You can’t perform that action at this time.
0 commit comments