diff --git a/Cargo.toml b/Cargo.toml index 90209b7..e2034ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ write = [] union = [] specialization = [] may_dangle = [] +drain_filter = [] # UNSTABLE FEATURES (requires Rust nightly) # Enable to use the #[debugger_visualizer] attribute. diff --git a/src/lib.rs b/src/lib.rs index 960c5a9..3723851 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -410,6 +410,7 @@ impl<'a, T: 'a + Array> Drop for Drain<'a, T> { } } +#[cfg(feature = "drain_filter")] /// An iterator which uses a closure to determine if an element should be removed. /// /// Returned from [`SmallVec::drain_filter`][1]. @@ -437,6 +438,7 @@ where panic_flag: bool, } +#[cfg(feature = "drain_filter")] impl fmt::Debug for DrainFilter<'_, T, F> where F: FnMut(&mut T::Item) -> bool, @@ -448,6 +450,7 @@ where } } +#[cfg(feature = "drain_filter")] impl Iterator for DrainFilter<'_, T, F> where F: FnMut(&mut T::Item) -> bool, @@ -487,6 +490,7 @@ where } } +#[cfg(feature = "drain_filter")] impl Drop for DrainFilter<'_, T, F> where F: FnMut(&mut T::Item) -> bool, @@ -974,6 +978,8 @@ impl SmallVec { } } + + #[cfg(feature = "drain_filter")] /// Creates an iterator which uses a closure to determine if an element should be removed. /// /// If the closure returns true, the element is removed and yielded. If the closure returns diff --git a/src/tests.rs b/src/tests.rs index 6d219e7..9627615 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -990,10 +990,10 @@ fn test_size() { assert_eq!(24, size_of::>()); } -// #[cfg(feature("drain_filter"))] +#[cfg(feature = "drain_filter")] #[test] fn drain_filter() { - let mut a: SmallVec<[u8; 2]> = SmallVec::from_slice(&[1u8, 2, 3, 4, 5, 6, 7, 8]); + let mut a: SmallVec<[u8; 2]> = smallvec![1u8, 2, 3, 4, 5, 6, 7, 8]; let b: SmallVec<[u8; 2]> = a.drain_filter(|x| *x % 3 == 0).collect();