Skip to content

Commit

Permalink
Compilation fixes for the latest nightly compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
slightlyoutofphase committed Sep 30, 2022
1 parent 043ff94 commit 5187d15
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
keywords = ["vec", "array", "no_std", "vector", "stack"]
categories = ["data-structures", "no-std"]
Expand Down
4 changes: 2 additions & 2 deletions demo/main_demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static LEFT: StaticVec<MyStruct, 4> = staticvec![
MyStruct::new("d")
];
static RIGHT: StaticVec<MyStruct, 2> = staticvec![MyStruct::new("e"), MyStruct::new("f")];
static CONCATENATED: StaticVec<MyStruct, 6> = LEFT.concat(&RIGHT);
//static CONCATENATED: StaticVec<MyStruct, 6> = LEFT.concat(&RIGHT);
static SPLIT: (StaticVec<usize, 2>, StaticVec<usize, 4>) =
staticvec![1usize, 2usize, 3usize, 4usize, 5usize, 6usize].split_at::<2>();

Expand Down Expand Up @@ -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);
Expand Down
71 changes: 29 additions & 42 deletions src/iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -225,22 +225,22 @@ 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;
fn size(&self) -> usize {
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)]
Expand Down Expand Up @@ -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)
Expand All @@ -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)]
Expand Down Expand Up @@ -614,7 +612,7 @@ impl<T, const N: usize> DoubleEndedIterator for StaticVecIntoIter<T, N> {
}
}

impl<T, const N: usize> const ExactSizeIterator for StaticVecIntoIter<T, N> {
impl<T, const N: usize> ExactSizeIterator for StaticVecIntoIter<T, N> {
#[inline(always)]
fn len(&self) -> usize {
self.end - self.start
Expand All @@ -626,20 +624,20 @@ impl<T, const N: usize> const ExactSizeIterator for StaticVecIntoIter<T, N> {
}
}

impl<T, const N: usize> const FusedIterator for StaticVecIntoIter<T, N> {}
unsafe impl<T, const N: usize> const TrustedLen for StaticVecIntoIter<T, N> {}
impl<T, const N: usize> FusedIterator for StaticVecIntoIter<T, N> {}
unsafe impl<T, const N: usize> TrustedLen for StaticVecIntoIter<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<T: Copy, const N: usize> const TrustedRandomAccessNoCoerce for StaticVecIntoIter<T, N> {
unsafe impl<T: Copy, const N: usize> TrustedRandomAccessNoCoerce for StaticVecIntoIter<T, N> {
const MAY_HAVE_SIDE_EFFECT: bool = false;

fn size(&self) -> usize {
self.end - self.start
}
}
unsafe impl<T: Sync, const N: usize> const Sync for StaticVecIntoIter<T, N> {}
unsafe impl<T: Send, const N: usize> const Send for StaticVecIntoIter<T, N> {}
unsafe impl<T: Sync, const N: usize> Sync for StaticVecIntoIter<T, N> {}
unsafe impl<T: Send, const N: usize> Send for StaticVecIntoIter<T, N> {}

impl<T: Clone, const N: usize> Clone for StaticVecIntoIter<T, N> {
#[inline(always)]
Expand Down Expand Up @@ -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()
Expand All @@ -770,21 +768,21 @@ 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;
fn size(&self) -> usize {
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)]
Expand Down Expand Up @@ -879,9 +877,7 @@ impl<T, I: Iterator<Item = T> + DoubleEndedIterator, const N: usize> DoubleEnded
}
}

impl<T, I: Iterator<Item = T>, const N: usize> const ExactSizeIterator
for StaticVecSplice<T, I, N>
{
impl<T, I: Iterator<Item = T>, const N: usize> ExactSizeIterator for StaticVecSplice<T, I, N> {
#[inline(always)]
fn len(&self) -> usize {
self.end - self.start
Expand All @@ -893,19 +889,10 @@ impl<T, I: Iterator<Item = T>, const N: usize> const ExactSizeIterator
}
}

impl<T, I: Iterator<Item = T>, const N: usize> const FusedIterator for StaticVecSplice<T, I, N> {}
unsafe impl<T, I: Iterator<Item = T>, const N: usize> const TrustedLen
for StaticVecSplice<T, I, N>
{
}
unsafe impl<T: Sync, I: Iterator<Item = T>, const N: usize> const Sync
for StaticVecSplice<T, I, N>
{
}
unsafe impl<T: Send, I: Iterator<Item = T>, const N: usize> const Send
for StaticVecSplice<T, I, N>
{
}
impl<T, I: Iterator<Item = T>, const N: usize> FusedIterator for StaticVecSplice<T, I, N> {}
unsafe impl<T, I: Iterator<Item = T>, const N: usize> TrustedLen for StaticVecSplice<T, I, N> {}
unsafe impl<T: Sync, I: Iterator<Item = T>, const N: usize> Sync for StaticVecSplice<T, I, N> {}
unsafe impl<T: Send, I: Iterator<Item = T>, const N: usize> Send for StaticVecSplice<T, I, N> {}

impl<T: Debug, I: Iterator<Item = T>, const N: usize> Debug for StaticVecSplice<T, I, N> {
#[inline(always)]
Expand Down
1 change: 1 addition & 0 deletions src/trait_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ impl<T: Eq, const N: usize> Eq for StaticVec<T, N> {}

/// A helper trait for specialization-based implementations of [`Extend`](core::iter::Extend) and
/// ['FromIterator`](core::iter::FromIterator).
#[const_trait]
pub(crate) trait ExtendEx<T, I> {
fn extend_ex(&mut self, iter: I);
fn from_iter_ex(iter: I) -> Self;
Expand Down

0 comments on commit 5187d15

Please sign in to comment.