Skip to content

Commit

Permalink
Remove From<HeaderValue> for String and str
Browse files Browse the repository at this point in the history
  • Loading branch information
caspervonb committed Aug 12, 2023
1 parent b140740 commit 1dc000b
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions async-nats/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,24 +243,6 @@ impl AsRef<str> for HeaderValue {
}
}

impl From<HeaderValue> for String {
fn from(header: HeaderValue) -> Self {
header.to_string()
}
}

impl From<&HeaderValue> for String {
fn from(header: &HeaderValue) -> Self {
header.to_string()
}
}

impl<'a> From<&'a HeaderValue> for &'a str {
fn from(header: &'a HeaderValue) -> Self {
header.inner.as_str()
}
}

impl FromStr for HeaderValue {
type Err = ParseHeaderValueError;

Expand Down Expand Up @@ -297,7 +279,7 @@ impl HeaderValue {
}

pub fn as_str(&self) -> &str {
self.into()
self.inner.as_str()
}
}

Expand Down Expand Up @@ -614,10 +596,10 @@ mod tests {

assert_eq!(headers.get("Key").unwrap().to_string(), "value");

let key: String = headers.get("Key").unwrap().into();
let key: String = headers.get("Key").unwrap().as_str().into();
assert_eq!(key, "value".to_string());

let key: String = headers.get("Key").unwrap().to_owned().into();
let key: String = headers.get("Key").unwrap().as_str().to_owned();
assert_eq!(key, "value".to_string());

assert_eq!(headers.get("Key").unwrap().as_str(), "value");
Expand Down

0 comments on commit 1dc000b

Please sign in to comment.