Skip to content

Commit b775be8

Browse files
authored
Merge pull request #304 from brightly-salty/fix-formatting
Fix formatting for StatusCode
2 parents 8d44aec + bafadd2 commit b775be8

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

src/cache/cache_control/cache_directive.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,29 @@ impl CacheDirective {
4747
/// Check whether this directive is valid in an HTTP request.
4848
pub fn valid_in_req(&self) -> bool {
4949
use CacheDirective::*;
50-
matches!(self,
51-
MaxAge(_) | MaxStale(_) | MinFresh(_) | NoCache | NoStore | NoTransform
52-
| OnlyIfCached)
50+
matches!(
51+
self,
52+
MaxAge(_) | MaxStale(_) | MinFresh(_) | NoCache | NoStore | NoTransform | OnlyIfCached
53+
)
5354
}
5455

5556
/// Check whether this directive is valid in an HTTP response.
5657
pub fn valid_in_res(&self) -> bool {
5758
use CacheDirective::*;
58-
matches!(self,
59+
matches!(
60+
self,
5961
MustRevalidate
60-
| NoCache
61-
| NoStore
62-
| NoTransform
63-
| Public
64-
| Private
65-
| ProxyRevalidate
66-
| MaxAge(_)
67-
| SMaxAge(_)
68-
| StaleIfError(_)
69-
| StaleWhileRevalidate(_))
62+
| NoCache
63+
| NoStore
64+
| NoTransform
65+
| Public
66+
| Private
67+
| ProxyRevalidate
68+
| MaxAge(_)
69+
| SMaxAge(_)
70+
| StaleIfError(_)
71+
| StaleWhileRevalidate(_)
72+
)
7073
}
7174

7275
/// Create an instance from a string slice.

src/proxies/forwarded.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ mod tests {
545545
assert_eq!(forwarded.forwarded_for(), vec!["client.com"]);
546546
assert_eq!(forwarded.host(), Some("host.com"));
547547
assert_eq!(forwarded.proto(), Some("https"));
548-
assert!(matches!(forwarded, Forwarded{..}));
548+
assert!(matches!(forwarded, Forwarded { .. }));
549549
Ok(())
550550
}
551551

@@ -644,7 +644,7 @@ mod tests {
644644
assert_eq!(forwarded.forwarded_for(), vec!["client"]);
645645
assert_eq!(forwarded.host(), Some("example.com"));
646646
assert_eq!(forwarded.proto(), Some("https"));
647-
assert!(matches!(forwarded, Forwarded{..}));
647+
assert!(matches!(forwarded, Forwarded { .. }));
648648
Ok(())
649649
}
650650

src/status_code.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use serde::de::{Error as DeError, Unexpected, Visitor};
22
use serde::{Deserialize, Deserializer, Serialize, Serializer};
3-
use std::fmt::{self, Display};
3+
use std::fmt::{self, Debug, Display};
44

55
/// HTTP response status codes.
66
///
77
/// As defined by [rfc7231 section 6](https://tools.ietf.org/html/rfc7231#section-6).
88
/// [Read more](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
99
#[repr(u16)]
10-
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
10+
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
1111
pub enum StatusCode {
1212
/// 100 Continue
1313
///
@@ -704,9 +704,15 @@ impl PartialEq<u16> for StatusCode {
704704
}
705705
}
706706

707+
impl Debug for StatusCode {
708+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
709+
write!(f, "{}: {}", *self as u16, self.canonical_reason())
710+
}
711+
}
712+
707713
impl Display for StatusCode {
708714
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
709-
write!(f, "{}", *self as u16)
715+
write!(f, "{}: {}", *self as u16, self.canonical_reason())
710716
}
711717
}
712718

0 commit comments

Comments
 (0)