From 0a4195d0cb8a9f4a77d02b3fb424fb29c5239afa Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Mon, 3 Oct 2016 19:07:17 -0400 Subject: [PATCH 1/2] Remove unnecessary `VecLike` trait. --- lib.rs | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/lib.rs b/lib.rs index 0b20986..0ecc944 100644 --- a/lib.rs +++ b/lib.rs @@ -18,37 +18,6 @@ use std::slice; use SmallVecData::{Inline, Heap}; -pub trait VecLike: - ops::Index + - ops::IndexMut + - ops::Index, Output=[T]> + - ops::IndexMut> + - ops::Index, Output=[T]> + - ops::IndexMut> + - ops::Index, Output=[T]> + - ops::IndexMut> + - ops::Index + - ops::IndexMut + - ops::Deref + - ops::DerefMut + - Extend { - - fn len(&self) -> usize; - fn push(&mut self, value: T); -} - -impl VecLike for Vec { - #[inline] - fn len(&self) -> usize { - Vec::len(self) - } - - #[inline] - fn push(&mut self, value: T) { - Vec::push(self, value); - } -} - unsafe fn deallocate(ptr: *mut T, capacity: usize) { let _vec: Vec = Vec::from_raw_parts(ptr, 0, capacity); // Let it drop. @@ -150,12 +119,6 @@ impl SmallVec { pub fn inline_size(&self) -> usize { A::size() } - pub fn len(&self) -> usize { - self.len - } - pub fn is_empty(&self) -> bool { - self.len == 0 - } pub fn capacity(&self) -> usize { match self.data { Inline { .. } => A::size(), @@ -400,18 +363,6 @@ impl_index!(ops::RangeTo, [A::Item]); impl_index!(ops::RangeFull, [A::Item]); -impl VecLike for SmallVec { - #[inline] - fn len(&self) -> usize { - SmallVec::len(self) - } - - #[inline] - fn push(&mut self, value: A::Item) { - SmallVec::push(self, value); - } -} - impl FromIterator for SmallVec { fn from_iter>(iterable: I) -> SmallVec { let mut v = SmallVec::new(); From f266291f18893d4e3715d97212b03a5c3a0eb030 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Mon, 3 Oct 2016 19:07:33 -0400 Subject: [PATCH 2/2] Cleanup whitespace. --- lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib.rs b/lib.rs index 0ecc944..898e68b 100644 --- a/lib.rs +++ b/lib.rs @@ -482,11 +482,11 @@ impl Drop for IntoIter { impl Iterator for IntoIter { type Item = A::Item; - + #[inline] fn next(&mut self) -> Option { if self.current == self.end { - None + None } else { unsafe { @@ -508,7 +508,7 @@ impl DoubleEndedIterator for IntoIter { #[inline] fn next_back(&mut self) -> Option { if self.current == self.end { - None + None } else { unsafe { @@ -745,7 +745,7 @@ pub mod tests { self.0.set(self.0.get() + 1); } } - + { let cell = Cell::new(0); let mut v: SmallVec<[DropCounter; 2]> = SmallVec::new();