Skip to content

Commit be88520

Browse files
committed
cargo clippy
1 parent 7dcee4b commit be88520

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/conditional/etag.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::headers::{HeaderName, HeaderValue, Headers, ToHeaderValues, ETAG};
22
use crate::{Error, StatusCode};
33

4-
use std::fmt::Debug;
4+
use std::fmt::{self, Debug, Display};
55
use std::option;
66

77
/// HTTP Entity Tags.
@@ -94,14 +94,6 @@ impl ETag {
9494
matches!(self, Self::Weak(_))
9595
}
9696

97-
/// Convert an ETag to a String.
98-
pub fn to_string(&self) -> String {
99-
match self {
100-
Self::Strong(s) => format!(r#""{}""#, s),
101-
Self::Weak(s) => format!(r#"W/"{}""#, s),
102-
}
103-
}
104-
10597
/// Create an Etag from a string.
10698
pub(crate) fn from_str(s: &str) -> crate::Result<Self> {
10799
let mut weak = false;
@@ -138,6 +130,15 @@ impl ETag {
138130
}
139131
}
140132

133+
impl Display for ETag {
134+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
135+
match self {
136+
Self::Strong(s) => write!(f, r#""{}""#, s),
137+
Self::Weak(s) => write!(f, r#"W/"{}""#, s),
138+
}
139+
}
140+
}
141+
141142
impl ToHeaderValues for ETag {
142143
type Iter = option::IntoIter<HeaderValue>;
143144
fn to_header_values(&self) -> crate::Result<Self::Iter> {

0 commit comments

Comments
 (0)