From 8d2508bfebb57df15d2bbaa9e5f3433d18af6685 Mon Sep 17 00:00:00 2001
From: Carl Lerche <me@carllerche.com>
Date: Fri, 14 Oct 2016 20:42:16 -0700
Subject: [PATCH] Tweak Bytes helpers

---
 src/imp/buf/block.rs |  2 +-
 src/imp/bytes/mod.rs | 10 ++++++++--
 src/lib.rs           |  1 +
 test/test_rope.rs    | 10 +++++-----
 4 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/imp/buf/block.rs b/src/imp/buf/block.rs
index b42ac8c..b6b7049 100644
--- a/src/imp/buf/block.rs
+++ b/src/imp/buf/block.rs
@@ -145,7 +145,7 @@ impl BlockBuf {
 
             ret = Some(match ret.take() {
                 Some(curr) => {
-                    curr.concat(&segment)
+                    curr.concat(segment)
                 }
                 None => segment,
             });
diff --git a/src/imp/bytes/mod.rs b/src/imp/bytes/mod.rs
index e5edf8b..05c9efc 100644
--- a/src/imp/bytes/mod.rs
+++ b/src/imp/bytes/mod.rs
@@ -92,8 +92,14 @@ impl Bytes {
         }
     }
 
-    pub fn concat(&self, other: &Bytes) -> Bytes {
-        Rope::concat(self.clone(), other.clone())
+    /// Concatenate two `Bytes` together
+    pub fn concat(self, other: Bytes) -> Bytes {
+        Rope::concat(self, other)
+    }
+
+    /// Divide one `Bytes` into two at an index
+    pub fn split_at(self, mid: usize) -> (Bytes, Bytes) {
+        (self.slice_to(mid), self.slice_from(mid))
     }
 
     /// Returns a new ByteStr value containing the byte range between `begin`
diff --git a/src/lib.rs b/src/lib.rs
index 4172afb..f8857fc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -29,6 +29,7 @@ pub mod buf {
     pub use imp::buf::slice::SliceBuf;
     pub use imp::buf::append::AppendBuf;
     pub use imp::buf::block::{BlockBuf, BlockBufCursor};
+    pub use imp::buf::bound::{BoundBuf};
     pub use imp::buf::ring::RingBuf;
     pub use imp::buf::take::Take;
     pub use imp::bytes::BytesBuf;
diff --git a/test/test_rope.rs b/test/test_rope.rs
index e32dced..8054b8b 100644
--- a/test/test_rope.rs
+++ b/test/test_rope.rs
@@ -57,7 +57,7 @@ pub fn test_rope_concat_two_byte_str() {
     let left = Bytes::from(TEST_BYTES_1);
     let right = Bytes::from(TEST_BYTES_2);
 
-    let both = left.concat(&right);
+    let both = left.concat(right);
 
     assert_eq!(both.len(), TEST_BYTES_1.len() + TEST_BYTES_2.len());
 
@@ -71,13 +71,13 @@ pub fn test_rope_concat_two_byte_str() {
 #[test]
 pub fn test_rope_equality() {
     let a = Bytes::from(&b"Mary had a little lamb, its fleece was white as snow; "[..])
-        .concat(&Bytes::from(&b"And everywhere that Mary went, the lamb was sure to go."[..]));
+        .concat(Bytes::from(&b"And everywhere that Mary went, the lamb was sure to go."[..]));
 
     let b = Bytes::from(&b"Mary had a little lamb, "[..])
-        .concat(&Bytes::from(&b"its fleece was white as snow; "[..]))
+        .concat(Bytes::from(&b"its fleece was white as snow; "[..]))
         .concat(
-            &Bytes::from(&b"And everywhere that Mary went, "[..])
-                .concat(&Bytes::from(&b"the lamb was sure to go."[..])));
+            Bytes::from(&b"And everywhere that Mary went, "[..])
+                .concat(Bytes::from(&b"the lamb was sure to go."[..])));
 
     assert_eq!(a, b);
 }
-- 
GitLab