Skip to content

Commit

Permalink
Remove VecLike (#165)
Browse files Browse the repository at this point in the history
This is a backwards incompatible change. VecLike was
deprecated in 0.6.0 released 2 years ago, and that should
have given plenty of time to remove its usages.
  • Loading branch information
KamilaBorowska authored and emilio committed Oct 19, 2019
1 parent b9321bb commit 9d00721
Showing 1 changed file with 0 additions and 73 deletions.
73 changes: 0 additions & 73 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,54 +142,6 @@ macro_rules! debug_unreachable {
};
}

/// Common operations implemented by both `Vec` and `SmallVec`.
///
/// This can be used to write generic code that works with both `Vec` and `SmallVec`.
///
/// ## Example
///
/// ```rust
/// use smallvec::{VecLike, SmallVec};
///
/// fn initialize<V: VecLike<u8>>(v: &mut V) {
/// for i in 0..5 {
/// v.push(i);
/// }
/// }
///
/// let mut vec = Vec::new();
/// initialize(&mut vec);
///
/// let mut small_vec = SmallVec::<[u8; 8]>::new();
/// initialize(&mut small_vec);
/// ```
#[deprecated(note = "Use `Extend` and `Deref<[T]>` instead")]
pub trait VecLike<T>:
ops::Index<usize, Output = T>
+ ops::IndexMut<usize>
+ ops::Index<ops::Range<usize>, Output = [T]>
+ ops::IndexMut<ops::Range<usize>>
+ ops::Index<ops::RangeFrom<usize>, Output = [T]>
+ ops::IndexMut<ops::RangeFrom<usize>>
+ ops::Index<ops::RangeTo<usize>, Output = [T]>
+ ops::IndexMut<ops::RangeTo<usize>>
+ ops::Index<ops::RangeFull, Output = [T]>
+ ops::IndexMut<ops::RangeFull>
+ ops::DerefMut<Target = [T]>
+ Extend<T>
{
/// Append an element to the vector.
fn push(&mut self, value: T);
}

#[allow(deprecated)]
impl<T> VecLike<T> for Vec<T> {
#[inline]
fn push(&mut self, value: T) {
Vec::push(self, value);
}
}

/// Trait to be implemented by a collection that can be extended from a slice
///
/// ## Example
Expand Down Expand Up @@ -1357,14 +1309,6 @@ where
}
}

#[allow(deprecated)]
impl<A: Array> VecLike<A::Item> for SmallVec<A> {
#[inline]
fn push(&mut self, value: A::Item) {
SmallVec::push(self, value);
}
}

impl<A: Array> FromIterator<A::Item> for SmallVec<A> {
fn from_iter<I: IntoIterator<Item = A::Item>>(iterable: I) -> SmallVec<A> {
let mut v = SmallVec::new();
Expand Down Expand Up @@ -2227,23 +2171,6 @@ mod tests {
assert_eq!(vec.drain().len(), 3);
}

#[test]
#[allow(deprecated)]
fn veclike_deref_slice() {
use super::VecLike;

fn test<T: VecLike<i32>>(vec: &mut T) {
assert!(!vec.is_empty());
assert_eq!(vec.len(), 3);

vec.sort();
assert_eq!(&vec[..], [1, 2, 3]);
}

let mut vec = SmallVec::<[i32; 2]>::from(&[3, 1, 2][..]);
test(&mut vec);
}

#[test]
fn shrink_to_fit_unspill() {
let mut vec = SmallVec::<[u8; 2]>::from_iter(0..3);
Expand Down

0 comments on commit 9d00721

Please sign in to comment.