Skip to content

Commit

Permalink
core: AnyBytes from boxed slice
Browse files Browse the repository at this point in the history
Avoids an unnecessarity roundtrip through `Vec<u8>` in private#731.
  • Loading branch information
kim committed Apr 22, 2024
1 parent c9381af commit f40493c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/core/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ impl From<Vec<u8>> for AnyBytes {
}
}

impl From<Box<[u8]>> for AnyBytes {
fn from(b: Box<[u8]>) -> Self {
Self::Bytes(b.into())
}
}

impl AsRef<[u8]> for AnyBytes {
fn as_ref(&self) -> &[u8] {
self
Expand Down

0 comments on commit f40493c

Please sign in to comment.