Skip to content

Commit

Permalink
Remove more features
Browse files Browse the repository at this point in the history
  • Loading branch information
c410-f3r committed Dec 27, 2020
1 parent 2964a84 commit c70364b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
21 changes: 0 additions & 21 deletions src/lib.rs
Expand Up @@ -1933,34 +1933,13 @@ impl<'a> Drop for SetLenOnDrop<'a> {
}
}

#[cfg(feature = "const_generics")]
unsafe impl<T, const N: usize> Array for [T; N] {
type Item = T;
fn size() -> usize {
N
}
}

#[cfg(not(feature = "const_generics"))]
macro_rules! impl_array(
($($size:expr),+) => {
$(
unsafe impl<T> Array for [T; $size] {
type Item = T;
fn size() -> usize { $size }
}
)+
}
);

#[cfg(not(feature = "const_generics"))]
impl_array!(
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 36, 0x40, 0x60, 0x80,
0x100, 0x200, 0x400, 0x600, 0x800, 0x1000, 0x2000, 0x4000, 0x6000, 0x8000, 0x10000, 0x20000,
0x40000, 0x60000, 0x80000, 0x10_0000
);

/// Convenience trait for constructing a `SmallVec`
pub trait ToSmallVec<A: Array> {
/// Construct a new `SmallVec` from a slice.
Expand Down
11 changes: 5 additions & 6 deletions src/tests.rs
Expand Up @@ -609,6 +609,11 @@ fn test_from() {
let small_vec: SmallVec<[u8; 128]> = SmallVec::from(array);
assert_eq!(&*small_vec, vec![99u8; 128].as_slice());
drop(small_vec);

let array = [99; 987];
let small_vec: SmallVec<[u8; 987]> = SmallVec::from(array);
assert_eq!(&*small_vec, vec![99u8; 987].as_slice());
drop(small_vec);
}

#[test]
Expand Down Expand Up @@ -890,12 +895,6 @@ fn grow_spilled_same_size() {
assert_eq!(v[..], [0, 1, 2]);
}

#[cfg(feature = "const_generics")]
#[test]
fn const_generics() {
let _v = SmallVec::<[i32; 987]>::default();
}

#[test]
fn empty_macro() {
let _v: SmallVec<[u8; 1]> = smallvec![];
Expand Down

0 comments on commit c70364b

Please sign in to comment.