From 68a0abf687ed147e878f1766c0da90f988774d50 Mon Sep 17 00:00:00 2001
From: Carl Lerche <me@carllerche.com>
Date: Mon, 23 Mar 2015 23:38:53 -0700
Subject: [PATCH] Implement slice for small ByteStr

---
 src/byte_str.rs | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/byte_str.rs b/src/byte_str.rs
index 831c9c5..5619d08 100644
--- a/src/byte_str.rs
+++ b/src/byte_str.rs
@@ -152,6 +152,10 @@ impl SmallByteStr {
 
         Some(ret)
     }
+
+    pub fn as_slice(&self) -> &[u8] {
+        &self.bytes[..self.len as usize]
+    }
 }
 
 impl ByteStr for SmallByteStr {
@@ -169,12 +173,8 @@ impl ByteStr for SmallByteStr {
         self.len as usize
     }
 
-    fn slice(&self, _begin: usize, _end: usize) -> Bytes {
-        unimplemented!();
-    }
-
-    fn split_at(&self, _mid: usize) -> (Bytes, Bytes) {
-        unimplemented!();
+    fn slice(&self, begin: usize, end: usize) -> Bytes {
+        Bytes::from_slice(&self.as_slice()[begin..end])
     }
 }
 
-- 
GitLab