Skip to content

Commit

Permalink
Remove the N const generic from PrimesIter, as it doesn't use it. (
Browse files Browse the repository at this point in the history
…#33)

* Remove unnecessary const generic in PrimesIter

* Add changes to changelog
  • Loading branch information
JSorngard authored May 28, 2024
1 parent baab5aa commit 11fc216
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
This file contains the changes to the crate since version 0.4.8.

# 0.7.0

## Breaking changes

- `PrimesIter` no longer takes a const generic.

# 0.6.2

- Minor documentation tweaks.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "const-primes"
authors = ["Johanna Sörngård (jsorngard@gmail.com)"]
version = "0.6.2"
version = "0.7.0"
edition = "2021"
license = "MIT OR Apache-2.0"
keywords = ["const", "primes"]
Expand Down
16 changes: 8 additions & 8 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl<const N: usize> Primes<N> {
/// assert_eq!(primes.as_slice(), &[19, 23, 29]);
/// ```
#[inline]
pub fn iter(&self) -> PrimesIter<'_, N> {
pub fn iter(&self) -> PrimesIter<'_> {
PrimesIter::new(IntoIterator::into_iter(&self.primes))
}

Expand Down Expand Up @@ -422,9 +422,9 @@ mod primes_iter {
/// Created by the [`iter`](super::Primes::iter) function on [`Primes`](super::Primes),
/// see it for more information.
#[derive(Debug, Clone)]
pub struct PrimesIter<'a, const N: usize>(core::slice::Iter<'a, Underlying>);
pub struct PrimesIter<'a>(core::slice::Iter<'a, Underlying>);

impl<'a, const N: usize> PrimesIter<'a, N> {
impl<'a> PrimesIter<'a> {
pub(crate) const fn new(iter: core::slice::Iter<'a, Underlying>) -> Self {
Self(iter)
}
Expand All @@ -435,7 +435,7 @@ mod primes_iter {
}
}

impl<'a, const N: usize> Iterator for PrimesIter<'a, N> {
impl<'a> Iterator for PrimesIter<'a> {
type Item = &'a Underlying;

#[inline]
Expand Down Expand Up @@ -464,16 +464,16 @@ mod primes_iter {
}
}

impl<'a, const N: usize> ExactSizeIterator for PrimesIter<'a, N> {
impl<'a> ExactSizeIterator for PrimesIter<'a> {
#[inline]
fn len(&self) -> usize {
self.0.len()
}
}

impl<'a, const N: usize> FusedIterator for PrimesIter<'a, N> {}
impl<'a> FusedIterator for PrimesIter<'a> {}

impl<'a, const N: usize> DoubleEndedIterator for PrimesIter<'a, N> {
impl<'a> DoubleEndedIterator for PrimesIter<'a> {
#[inline]
fn next_back(&mut self) -> Option<Self::Item> {
self.0.next_back()
Expand Down Expand Up @@ -560,7 +560,7 @@ mod primes_into_iter {
}

impl<'a, const N: usize> IntoIterator for &'a Primes<N> {
type IntoIter = PrimesIter<'a, N>;
type IntoIter = PrimesIter<'a>;
type Item = &'a Underlying;
fn into_iter(self) -> Self::IntoIter {
PrimesIter::new(IntoIterator::into_iter(&self.primes))
Expand Down

0 comments on commit 11fc216

Please sign in to comment.