Skip to content
Snippets Groups Projects
Commit 68a0abf6 authored by Carl Lerche's avatar Carl Lerche
Browse files

Implement slice for small ByteStr

parent bd2c643e
No related branches found
No related tags found
No related merge requests found
...@@ -152,6 +152,10 @@ impl SmallByteStr { ...@@ -152,6 +152,10 @@ impl SmallByteStr {
Some(ret) Some(ret)
} }
pub fn as_slice(&self) -> &[u8] {
&self.bytes[..self.len as usize]
}
} }
impl ByteStr for SmallByteStr { impl ByteStr for SmallByteStr {
...@@ -169,12 +173,8 @@ impl ByteStr for SmallByteStr { ...@@ -169,12 +173,8 @@ impl ByteStr for SmallByteStr {
self.len as usize self.len as usize
} }
fn slice(&self, _begin: usize, _end: usize) -> Bytes { fn slice(&self, begin: usize, end: usize) -> Bytes {
unimplemented!(); Bytes::from_slice(&self.as_slice()[begin..end])
}
fn split_at(&self, _mid: usize) -> (Bytes, Bytes) {
unimplemented!();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment