Skip to content

Commit

Permalink
add From<Cow<'static, str>> and From<Cow<'static, [u8]>> for Body
Browse files Browse the repository at this point in the history
  • Loading branch information
jbr committed Oct 16, 2023
1 parent bc28015 commit 7a7ff2d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions http/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,21 @@ impl From<Vec<u8>> for Body {
}
}

impl From<Cow<'static, [u8]>> for Body {
fn from(value: Cow<'static, [u8]>) -> Self {
Self::new_static(value)
}
}

impl From<Cow<'static, str>> for Body {
fn from(value: Cow<'static, str>) -> Self {
match value {
Cow::Borrowed(b) => b.into(),
Cow::Owned(o) => o.into(),
}
}
}

#[cfg(test)]
mod test_bytes_to_read {
#[test]
Expand Down

0 comments on commit 7a7ff2d

Please sign in to comment.