From 511194ccc7f39c78f905a13900cbdbe56549f3f1 Mon Sep 17 00:00:00 2001 From: UnicodingUnicorn <7555ic@gmail.com> Date: Fri, 21 Feb 2020 23:12:51 +0800 Subject: [PATCH] added to_smallvec extension trait to slice primitive --- lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib.rs b/lib.rs index 0c8243e..d43700a 100644 --- a/lib.rs +++ b/lib.rs @@ -1684,6 +1684,17 @@ impl_array!( 0x40000, 0x60000, 0x80000, 0x10_0000 ); +trait ToSmallVec { + fn to_smallvec(&self) -> SmallVec; +} + +impl ToSmallVec for [A::Item] + where A::Item: Copy { + fn to_smallvec(&self) -> SmallVec { + SmallVec::from_slice(self) + } +} + #[cfg(test)] mod tests { use crate::SmallVec;