From 6f97d04077b9dec5f67f3749f6ed753bbfe340fa Mon Sep 17 00:00:00 2001 From: Carl Lerche <me@carllerche.com> Date: Fri, 7 Oct 2016 14:27:26 -0700 Subject: [PATCH] Add IntoBuf impls for non-ref types --- src/imp/buf/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/imp/buf/mod.rs b/src/imp/buf/mod.rs index d13a99b..8c7644f 100644 --- a/src/imp/buf/mod.rs +++ b/src/imp/buf/mod.rs @@ -399,6 +399,14 @@ impl<'a> IntoBuf for &'a &'static [u8] { } } +impl IntoBuf for Vec<u8> { + type Buf = io::Cursor<Vec<u8>>; + + fn into_buf(self) -> Self::Buf { + io::Cursor::new(self) + } +} + impl<'a> IntoBuf for &'a Vec<u8> { type Buf = io::Cursor<&'a [u8]>; @@ -407,6 +415,14 @@ impl<'a> IntoBuf for &'a Vec<u8> { } } +impl IntoBuf for () { + type Buf = io::Cursor<&'static [u8]>; + + fn into_buf(self) -> Self::Buf { + io::Cursor::new(&[]) + } +} + impl<'a> IntoBuf for &'a () { type Buf = io::Cursor<&'static [u8]>; -- GitLab