Skip to content

Commit 5467861

Browse files
authored
Merge pull request #142 from http-rs/from-bytes-owned
from_bytes should take an owned vec
2 parents 8afef1b + bc684b8 commit 5467861

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/headers/header_value.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ impl HeaderValue {
1818
/// # Error
1919
///
2020
/// This function will error if the bytes is not valid ASCII.
21-
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error> {
21+
pub fn from_bytes(bytes: Vec<u8>) -> Result<Self, Error> {
2222
crate::ensure!(bytes.is_ascii(), "Bytes should be valid ASCII");
2323

2424
// This is permitted because ASCII is valid UTF-8, and we just checked that.
25-
let string = unsafe { String::from_utf8_unchecked(bytes.to_vec()) };
25+
let string = unsafe { String::from_utf8_unchecked(bytes) };
2626
Ok(Self { inner: string })
2727
}
2828

0 commit comments

Comments
 (0)