diff --git a/Cargo.toml b/Cargo.toml index b7b4167..1acbbca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/slightlyoutofphase/staticvec" documentation = "https://docs.rs/staticvec/" license = "MIT OR Apache-2.0" readme = "README.md" -version = "0.11.8" +version = "0.11.9" authors = ["SlightlyOutOfPhase "] keywords = ["vec", "array", "no_std", "vector", "stack"] categories = ["data-structures", "no-std"] diff --git a/demo/main_demo.rs b/demo/main_demo.rs index 6f32e0d..2110f97 100644 --- a/demo/main_demo.rs +++ b/demo/main_demo.rs @@ -71,7 +71,7 @@ static LEFT: StaticVec = staticvec![ MyStruct::new("d") ]; static RIGHT: StaticVec = staticvec![MyStruct::new("e"), MyStruct::new("f")]; -static CONCATENATED: StaticVec = LEFT.concat(&RIGHT); +//static CONCATENATED: StaticVec = LEFT.concat(&RIGHT); static SPLIT: (StaticVec, StaticVec) = staticvec![1usize, 2usize, 3usize, 4usize, 5usize, 6usize].split_at::<2>(); @@ -160,7 +160,7 @@ fn main() { println!("{:?}", LOL); println!("{}", unsafe { MUTABLE.len() }); println!("{}", unsafe { MUTABLE.capacity() }); - println!("{:?}", CONCATENATED); + //println!("{:?}", CONCATENATED); println!("{:?}", SPLIT); println!("{:?}", BUILT); println!("{:?}", ALSO_BUILT); diff --git a/src/iterators.rs b/src/iterators.rs index da01800..571d41f 100644 --- a/src/iterators.rs +++ b/src/iterators.rs @@ -213,7 +213,7 @@ impl<'a, T: 'a, const N: usize> DoubleEndedIterator for StaticVecIterConst<'a, T } } -impl<'a, T: 'a, const N: usize> const ExactSizeIterator for StaticVecIterConst<'a, T, N> { +impl<'a, T: 'a, const N: usize> ExactSizeIterator for StaticVecIterConst<'a, T, N> { #[inline(always)] fn len(&self) -> usize { distance_between(self.end, self.start) @@ -225,12 +225,12 @@ impl<'a, T: 'a, const N: usize> const ExactSizeIterator for StaticVecIterConst<' } } -impl<'a, T: 'a, const N: usize> const FusedIterator for StaticVecIterConst<'a, T, N> {} -unsafe impl<'a, T: 'a, const N: usize> const TrustedLen for StaticVecIterConst<'a, T, N> {} +impl<'a, T: 'a, const N: usize> FusedIterator for StaticVecIterConst<'a, T, N> {} +unsafe impl<'a, T: 'a, const N: usize> TrustedLen for StaticVecIterConst<'a, T, N> {} // We hide this one just in case it gets removed from `std` later, so no one relies on us relying on // it. #[doc(hidden)] -unsafe impl<'a, T: 'a, const N: usize> const TrustedRandomAccessNoCoerce +unsafe impl<'a, T: 'a, const N: usize> TrustedRandomAccessNoCoerce for StaticVecIterConst<'a, T, N> { const MAY_HAVE_SIDE_EFFECT: bool = false; @@ -238,9 +238,9 @@ unsafe impl<'a, T: 'a, const N: usize> const TrustedRandomAccessNoCoerce distance_between(self.end, self.start) } } -unsafe impl<'a, T: 'a + Sync, const N: usize> const Sync for StaticVecIterConst<'a, T, N> {} +unsafe impl<'a, T: 'a + Sync, const N: usize> Sync for StaticVecIterConst<'a, T, N> {} // `StaticVecIterConst` works in terms of `&T`, which is sendable if / when `T` is `Sync`. -unsafe impl<'a, T: 'a + Sync, const N: usize> const Send for StaticVecIterConst<'a, T, N> {} +unsafe impl<'a, T: 'a + Sync, const N: usize> Send for StaticVecIterConst<'a, T, N> {} impl<'a, T: 'a, const N: usize> Clone for StaticVecIterConst<'a, T, N> { #[inline(always)] @@ -408,7 +408,7 @@ impl<'a, T: 'a, const N: usize> DoubleEndedIterator for StaticVecIterMut<'a, T, } } -impl<'a, T: 'a, const N: usize> const ExactSizeIterator for StaticVecIterMut<'a, T, N> { +impl<'a, T: 'a, const N: usize> ExactSizeIterator for StaticVecIterMut<'a, T, N> { #[inline(always)] fn len(&self) -> usize { distance_between(self.end, self.start) @@ -420,21 +420,19 @@ impl<'a, T: 'a, const N: usize> const ExactSizeIterator for StaticVecIterMut<'a, } } -impl<'a, T: 'a, const N: usize> const FusedIterator for StaticVecIterMut<'a, T, N> {} -unsafe impl<'a, T: 'a, const N: usize> const TrustedLen for StaticVecIterMut<'a, T, N> {} +impl<'a, T: 'a, const N: usize> FusedIterator for StaticVecIterMut<'a, T, N> {} +unsafe impl<'a, T: 'a, const N: usize> TrustedLen for StaticVecIterMut<'a, T, N> {} // We hide this one just in case it gets removed from `std` later, so no one relies on us relying on // it. #[doc(hidden)] -unsafe impl<'a, T: 'a, const N: usize> const TrustedRandomAccessNoCoerce - for StaticVecIterMut<'a, T, N> -{ +unsafe impl<'a, T: 'a, const N: usize> TrustedRandomAccessNoCoerce for StaticVecIterMut<'a, T, N> { const MAY_HAVE_SIDE_EFFECT: bool = false; fn size(&self) -> usize { distance_between(self.end, self.start) } } -unsafe impl<'a, T: 'a + Sync, const N: usize> const Sync for StaticVecIterMut<'a, T, N> {} -unsafe impl<'a, T: 'a + Send, const N: usize> const Send for StaticVecIterMut<'a, T, N> {} +unsafe impl<'a, T: 'a + Sync, const N: usize> Sync for StaticVecIterMut<'a, T, N> {} +unsafe impl<'a, T: 'a + Send, const N: usize> Send for StaticVecIterMut<'a, T, N> {} impl<'a, T: 'a + Debug, const N: usize> Debug for StaticVecIterMut<'a, T, N> { #[inline(always)] @@ -614,7 +612,7 @@ impl DoubleEndedIterator for StaticVecIntoIter { } } -impl const ExactSizeIterator for StaticVecIntoIter { +impl ExactSizeIterator for StaticVecIntoIter { #[inline(always)] fn len(&self) -> usize { self.end - self.start @@ -626,20 +624,20 @@ impl const ExactSizeIterator for StaticVecIntoIter { } } -impl const FusedIterator for StaticVecIntoIter {} -unsafe impl const TrustedLen for StaticVecIntoIter {} +impl FusedIterator for StaticVecIntoIter {} +unsafe impl TrustedLen for StaticVecIntoIter {} // We hide this one just in case it gets removed from `std` later, so no one relies on us relying on // it. #[doc(hidden)] -unsafe impl const TrustedRandomAccessNoCoerce for StaticVecIntoIter { +unsafe impl TrustedRandomAccessNoCoerce for StaticVecIntoIter { const MAY_HAVE_SIDE_EFFECT: bool = false; fn size(&self) -> usize { self.end - self.start } } -unsafe impl const Sync for StaticVecIntoIter {} -unsafe impl const Send for StaticVecIntoIter {} +unsafe impl Sync for StaticVecIntoIter {} +unsafe impl Send for StaticVecIntoIter {} impl Clone for StaticVecIntoIter { #[inline(always)] @@ -758,7 +756,7 @@ impl<'a, T: 'a, const N: usize> DoubleEndedIterator for StaticVecDrain<'a, T, N> } } -impl<'a, T: 'a, const N: usize> const ExactSizeIterator for StaticVecDrain<'a, T, N> { +impl<'a, T: 'a, const N: usize> ExactSizeIterator for StaticVecDrain<'a, T, N> { #[inline(always)] fn len(&self) -> usize { self.iter.len() @@ -770,12 +768,12 @@ impl<'a, T: 'a, const N: usize> const ExactSizeIterator for StaticVecDrain<'a, T } } -impl<'a, T: 'a, const N: usize> const FusedIterator for StaticVecDrain<'a, T, N> {} -unsafe impl<'a, T: 'a, const N: usize> const TrustedLen for StaticVecDrain<'a, T, N> {} +impl<'a, T: 'a, const N: usize> FusedIterator for StaticVecDrain<'a, T, N> {} +unsafe impl<'a, T: 'a, const N: usize> TrustedLen for StaticVecDrain<'a, T, N> {} // We hide this one just in case it gets removed from `std` later, so no one relies on us relying on // it. #[doc(hidden)] -unsafe impl<'a, T: Copy + 'a, const N: usize> const TrustedRandomAccessNoCoerce +unsafe impl<'a, T: Copy + 'a, const N: usize> TrustedRandomAccessNoCoerce for StaticVecDrain<'a, T, N> { const MAY_HAVE_SIDE_EFFECT: bool = false; @@ -783,8 +781,8 @@ unsafe impl<'a, T: Copy + 'a, const N: usize> const TrustedRandomAccessNoCoerce distance_between(self.iter.end, self.iter.start) } } -unsafe impl<'a, T: 'a + Sync, const N: usize> const Sync for StaticVecDrain<'a, T, N> {} -unsafe impl<'a, T: 'a + Send, const N: usize> const Send for StaticVecDrain<'a, T, N> {} +unsafe impl<'a, T: 'a + Sync, const N: usize> Sync for StaticVecDrain<'a, T, N> {} +unsafe impl<'a, T: 'a + Send, const N: usize> Send for StaticVecDrain<'a, T, N> {} impl<'a, T: 'a + Debug, const N: usize> Debug for StaticVecDrain<'a, T, N> { #[inline(always)] @@ -879,9 +877,7 @@ impl + DoubleEndedIterator, const N: usize> DoubleEnded } } -impl, const N: usize> const ExactSizeIterator - for StaticVecSplice -{ +impl, const N: usize> ExactSizeIterator for StaticVecSplice { #[inline(always)] fn len(&self) -> usize { self.end - self.start @@ -893,19 +889,10 @@ impl, const N: usize> const ExactSizeIterator } } -impl, const N: usize> const FusedIterator for StaticVecSplice {} -unsafe impl, const N: usize> const TrustedLen - for StaticVecSplice -{ -} -unsafe impl, const N: usize> const Sync - for StaticVecSplice -{ -} -unsafe impl, const N: usize> const Send - for StaticVecSplice -{ -} +impl, const N: usize> FusedIterator for StaticVecSplice {} +unsafe impl, const N: usize> TrustedLen for StaticVecSplice {} +unsafe impl, const N: usize> Sync for StaticVecSplice {} +unsafe impl, const N: usize> Send for StaticVecSplice {} impl, const N: usize> Debug for StaticVecSplice { #[inline(always)] diff --git a/src/trait_impls.rs b/src/trait_impls.rs index 9adf907..0a109b3 100644 --- a/src/trait_impls.rs +++ b/src/trait_impls.rs @@ -185,6 +185,7 @@ impl Eq for StaticVec {} /// A helper trait for specialization-based implementations of [`Extend`](core::iter::Extend) and /// ['FromIterator`](core::iter::FromIterator). +#[const_trait] pub(crate) trait ExtendEx { fn extend_ex(&mut self, iter: I); fn from_iter_ex(iter: I) -> Self;