From 9bb1366f3392a352c7e422bf87391b5dd7fa34d2 Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Sat, 17 Dec 2016 14:16:47 -0800 Subject: [PATCH 1/2] Add From> for EasyBuf --- src/io/frame.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/io/frame.rs b/src/io/frame.rs index 72b7b29c..c8c46dd3 100644 --- a/src/io/frame.rs +++ b/src/io/frame.rs @@ -177,6 +177,17 @@ impl<'a> DerefMut for EasyBufMut<'a> { } } +impl From> for EasyBuf { + fn from(vec: Vec) -> EasyBuf { + let end = vec.len(); + EasyBuf { + buf: Arc::new(vec), + start: 0, + end: end, + } + } +} + impl<'a> Drop for EasyBufMut<'a> { fn drop(&mut self) { *self.end = self.buf.len(); From 46d68f739aceec86d0ac0c540dbe11e42f4df81b Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Sat, 17 Dec 2016 14:17:52 -0800 Subject: [PATCH 2/2] Add Clone for EasyBuf --- src/io/frame.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/io/frame.rs b/src/io/frame.rs index c8c46dd3..cef83579 100644 --- a/src/io/frame.rs +++ b/src/io/frame.rs @@ -12,6 +12,7 @@ use io::Io; /// be handed out efficiently, each with a `'static` lifetime which keeps the /// data alive. The buffer also supports mutation but may require bytes to be /// copied to complete the operation. +#[derive(Clone)] pub struct EasyBuf { buf: Arc>, start: usize,