@@ -2,11 +2,11 @@ use HeaderValue;
22
33// Derives an enum to represent content codings and some helpful impls
44macro_rules! define_content_coding {
5- ( $( $coding: ident; $str: expr, ) +) => {
5+ ( $( $coding: ident; $str: expr, ) +) => {
66 #[ derive( Copy , Clone , Debug , Eq , PartialEq ) ]
7- /// Values that are used with headers like [`Content-Encoding`](self::ContentEncoding) or
7+ /// Values that are used with headers like [`Content-Encoding`](self::ContentEncoding) or
88 /// [`Accept-Encoding`](self::AcceptEncoding)
9- ///
9+ ///
1010 /// [RFC7231](https://www.iana.org/assignments/http-parameters/http-parameters.xhtml)
1111 pub enum ContentCoding {
1212 $(
@@ -17,12 +17,12 @@ macro_rules! define_content_coding {
1717
1818 impl ContentCoding {
1919 /// Returns a `&'static str` for a `ContentCoding`
20- ///
20+ ///
2121 /// # Example
22- ///
22+ ///
2323 /// ```
2424 /// use headers::ContentCoding;
25- ///
25+ ///
2626 /// let coding = ContentCoding::BROTLI;
2727 /// assert_eq!(coding.to_static(), "br");
2828 /// ```
@@ -33,20 +33,20 @@ macro_rules! define_content_coding {
3333 }
3434 }
3535
36- /// Given a `&str` returns a `ContentCoding`
37- ///
38- /// Note this will never fail, in the case of `&str` being an invalid content coding,
39- /// will return `ContentCoding::IDENTITY` because `'identity'` is generally always an
36+ /// Given a `&str` returns a `ContentCoding`
37+ ///
38+ /// Note this will never fail, in the case of `&str` being an invalid content coding,
39+ /// will return `ContentCoding::IDENTITY` because `'identity'` is generally always an
4040 /// accepted coding.
41- ///
41+ ///
4242 /// # Example
43- ///
43+ ///
4444 /// ```
4545 /// use headers::ContentCoding;
46- ///
46+ ///
4747 /// let invalid = ContentCoding::from_str("not a valid coding");
4848 /// assert_eq!(invalid, ContentCoding::IDENTITY);
49- ///
49+ ///
5050 /// let valid = ContentCoding::from_str("gzip");
5151 /// assert_eq!(valid, ContentCoding::GZIP);
5252 /// ```
@@ -56,18 +56,18 @@ macro_rules! define_content_coding {
5656 }
5757
5858 /// Given a `&str` will try to return a `ContentCoding`
59- ///
59+ ///
6060 /// Different from `ContentCoding::from_str(&str)`, if `&str` is an invalid content
6161 /// coding, it will return `Err(())`
62- ///
62+ ///
6363 /// # Example
64- ///
64+ ///
6565 /// ```
6666 /// use headers::ContentCoding;
67- ///
67+ ///
6868 /// let invalid = ContentCoding::try_from_str("not a valid coding");
6969 /// assert!(invalid.is_err());
70- ///
70+ ///
7171 /// let valid = ContentCoding::try_from_str("gzip");
7272 /// assert_eq!(valid.unwrap(), ContentCoding::GZIP);
7373 /// ```
@@ -128,12 +128,15 @@ mod tests {
128128 fn from_str ( ) {
129129 assert_eq ! ( ContentCoding :: from_str( "br" ) , ContentCoding :: BROTLI ) ;
130130 assert_eq ! ( ContentCoding :: from_str( "GZIP" ) , ContentCoding :: GZIP ) ;
131- assert_eq ! ( ContentCoding :: from_str( "blah blah" ) , ContentCoding :: IDENTITY ) ;
131+ assert_eq ! (
132+ ContentCoding :: from_str( "blah blah" ) ,
133+ ContentCoding :: IDENTITY
134+ ) ;
132135 }
133136
134137 #[ test]
135138 fn try_from_str ( ) {
136139 assert_eq ! ( ContentCoding :: try_from_str( "br" ) , Ok ( ContentCoding :: BROTLI ) ) ;
137140 assert_eq ! ( ContentCoding :: try_from_str( "blah blah" ) , Err ( ( ) ) ) ;
138141 }
139- }
142+ }
0 commit comments