Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rustdoc and clippy to github workflow #618

Closed
wants to merge 11 commits into from
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -27,6 +27,13 @@ jobs:
components: clippy
- run: RUSTFLAGS="--deny warnings" cargo clippy ${{ matrix.features }}

doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: RUSTDOCFLAGS="-Dwarnings" cargo doc --all-features

msrv:
runs-on: ubuntu-latest
env:
Expand Down
2 changes: 1 addition & 1 deletion benches/extra/zipslices.rs
Expand Up @@ -58,7 +58,7 @@ where
#[inline(always)]
pub fn from_slices(a: T, b: U) -> Self {
let minl = cmp::min(a.len(), b.len());
ZipSlices {
Self {
t: a,
u: b,
len: minl,
Expand Down
4 changes: 2 additions & 2 deletions examples/iris.rs
Expand Up @@ -25,7 +25,7 @@ enum ParseError {

impl From<ParseFloatError> for ParseError {
fn from(err: ParseFloatError) -> Self {
ParseError::Numeric(err)
Self::Numeric(err)
}
}

Expand All @@ -34,7 +34,7 @@ impl FromStr for Iris {
type Err = ParseError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut iris = Iris {
let mut iris = Self {
name: "".into(),
data: [0.; 4],
};
Expand Down
5 changes: 3 additions & 2 deletions src/adaptors/coalesce.rs
Expand Up @@ -17,9 +17,10 @@ where
f: F,
}

impl<I: Clone, F: Clone, C> Clone for CoalesceBy<I, F, C>
impl<I, F, C> Clone for CoalesceBy<I, F, C>
where
I: Iterator,
I: Clone + Iterator,
F: Clone,
C: CountItem<I::Item>,
C::CItem: Clone,
{
Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/mod.rs
Expand Up @@ -218,7 +218,7 @@ where
/// Split the `PutBack` into its parts.
#[inline]
pub fn into_parts(self) -> (Option<I::Item>, I) {
let PutBack { top, iter } = self;
let Self { top, iter } = self;
(top, iter)
}

Expand Down Expand Up @@ -689,7 +689,7 @@ pub struct Tuple1Combination<I> {

impl<I> From<I> for Tuple1Combination<I> {
fn from(iter: I) -> Self {
Tuple1Combination { iter }
Self { iter }
}
}

Expand Down
24 changes: 9 additions & 15 deletions src/adaptors/multi_product.rs
Expand Up @@ -77,16 +77,14 @@ where
multi_iters: &mut [MultiProductIter<I>],
mut state: MultiProductIterState,
) -> bool {
use self::MultiProductIterState::*;

if let Some((last, rest)) = multi_iters.split_last_mut() {
let on_first_iter = match state {
StartOfIter => {
MultiProductIterState::StartOfIter => {
let on_first_iter = !last.in_progress();
state = MidIter { on_first_iter };
state = MultiProductIterState::MidIter { on_first_iter };
on_first_iter
}
MidIter { on_first_iter } => on_first_iter,
MultiProductIterState::MidIter { on_first_iter } => on_first_iter,
};

if !on_first_iter {
Expand All @@ -95,7 +93,7 @@ where

if last.in_progress() {
true
} else if MultiProduct::iterate_last(rest, state) {
} else if Self::iterate_last(rest, state) {
last.reset();
last.iterate();
// If iterator is None twice consecutively, then iterator is
Expand All @@ -108,8 +106,8 @@ where
// Reached end of iterator list. On initialisation, return true.
// At end of iteration (final iterator finishes), finish.
match state {
StartOfIter => false,
MidIter { on_first_iter } => on_first_iter,
MultiProductIterState::StartOfIter => false,
MultiProductIterState::MidIter { on_first_iter } => on_first_iter,
}
}
}
Expand All @@ -125,11 +123,7 @@ where
/// Returns true if iteration has started and has not yet finished; false
/// otherwise.
fn in_progress(&self) -> bool {
if let Some(last) = self.0.last() {
last.in_progress()
} else {
false
}
self.0.last().map_or(false, MultiProductIter::in_progress)
}
}

Expand All @@ -139,7 +133,7 @@ where
I::Item: Clone,
{
fn new(iter: I) -> Self {
MultiProductIter {
Self {
cur: None,
iter: iter.clone(),
iter_orig: iter,
Expand Down Expand Up @@ -171,7 +165,7 @@ where
type Item = Vec<I::Item>;

fn next(&mut self) -> Option<Self::Item> {
if MultiProduct::iterate_last(&mut self.0, MultiProductIterState::StartOfIter) {
if Self::iterate_last(&mut self.0, MultiProductIterState::StartOfIter) {
Some(self.curr_iterator())
} else {
None
Expand Down
10 changes: 5 additions & 5 deletions src/combinations_with_replacement.rs
Expand Up @@ -65,13 +65,13 @@ where
fn next(&mut self) -> Option<Self::Item> {
// If this is the first iteration, return early
if self.first {
// In empty edge cases, stop iterating immediately
return if !(self.indices.is_empty() || self.pool.get_next()) {
None
// Otherwise, yield the initial state
} else {
return if self.indices.is_empty() || self.pool.get_next() {
// yield the initial state
self.first = false;
Some(self.current())
} else {
// In empty edge cases, stop iterating immediately
None
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/duplicates_impl.rs
Expand Up @@ -22,7 +22,7 @@ mod private {

impl<I: Iterator, Key: Eq + Hash, F> DuplicatesBy<I, Key, F> {
pub(crate) fn new(iter: I, key_method: F) -> Self {
DuplicatesBy {
Self {
iter,
meta: Meta {
used: HashMap::new(),
Expand Down Expand Up @@ -77,7 +77,7 @@ mod private {
type Item = I::Item;

fn next(&mut self) -> Option<Self::Item> {
let DuplicatesBy { iter, meta } = self;
let Self { iter, meta } = self;
iter.find_map(|v| meta.filter(v))
}

Expand Down Expand Up @@ -109,7 +109,7 @@ mod private {
F: KeyMethod<Key, I::Item>,
{
fn next_back(&mut self) -> Option<Self::Item> {
let DuplicatesBy { iter, meta } = self;
let Self { iter, meta } = self;
iter.rev().find_map(|v| meta.filter(v))
}
}
Expand Down