Skip to content

Commit 830331c

Browse files
author
Luca Palmieri
committed
Implement TryFrom<&'a str> for HeaderValue, deferring to the existing implementation of FromStr.
1 parent 2d8e00b commit 830331c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/headers/header_value.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ impl FromStr for HeaderValue {
8282
}
8383
}
8484

85+
impl<'a> std::convert::TryFrom<&'a str> for HeaderValue {
86+
type Error = Error;
87+
88+
fn try_from(value: &'a str) -> Result<Self, Self::Error> {
89+
Self::from_str(value)
90+
}
91+
}
92+
8593
impl Display for HeaderValue {
8694
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
8795
write!(f, "{}", self.inner)

0 commit comments

Comments
 (0)