From a97d8a3dbdb90be442c307fb1e80319bdb293c3e Mon Sep 17 00:00:00 2001 From: Philippe-Cholet Date: Fri, 3 Nov 2023 19:12:48 +0100 Subject: [PATCH] Add missing `must_use` attributes on adaptors --- src/adaptors/mod.rs | 1 + src/combinations_with_replacement.rs | 1 + src/multipeek_impl.rs | 1 + src/peek_nth.rs | 1 + src/put_back_n_impl.rs | 1 + src/rciter_impl.rs | 1 + 6 files changed, 6 insertions(+) diff --git a/src/adaptors/mod.rs b/src/adaptors/mod.rs index a19cd0e04..7d05a70b3 100644 --- a/src/adaptors/mod.rs +++ b/src/adaptors/mod.rs @@ -185,6 +185,7 @@ where /// item to the front of the iterator. /// /// Iterator element type is `I::Item`. +#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] pub struct PutBack where I: Iterator, diff --git a/src/combinations_with_replacement.rs b/src/combinations_with_replacement.rs index f1a0bc07d..88d858b5f 100644 --- a/src/combinations_with_replacement.rs +++ b/src/combinations_with_replacement.rs @@ -10,6 +10,7 @@ use crate::adaptors::checked_binomial; /// See [`.combinations_with_replacement()`](crate::Itertools::combinations_with_replacement) /// for more information. #[derive(Clone)] +#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] pub struct CombinationsWithReplacement where I: Iterator, diff --git a/src/multipeek_impl.rs b/src/multipeek_impl.rs index 339cf9781..00c5d4ea7 100644 --- a/src/multipeek_impl.rs +++ b/src/multipeek_impl.rs @@ -7,6 +7,7 @@ use std::iter::Fuse; /// See [`multipeek()`] for more information. #[derive(Clone, Debug)] +#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] pub struct MultiPeek where I: Iterator, diff --git a/src/peek_nth.rs b/src/peek_nth.rs index 5f7fb9396..e8546030d 100644 --- a/src/peek_nth.rs +++ b/src/peek_nth.rs @@ -5,6 +5,7 @@ use std::iter::Fuse; /// See [`peek_nth()`] for more information. #[derive(Clone, Debug)] +#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] pub struct PeekNth where I: Iterator, diff --git a/src/put_back_n_impl.rs b/src/put_back_n_impl.rs index 5fdbd5a98..9b23fa7d5 100644 --- a/src/put_back_n_impl.rs +++ b/src/put_back_n_impl.rs @@ -7,6 +7,7 @@ use crate::size_hint; /// /// Iterator element type is `I::Item`. #[derive(Debug, Clone)] +#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] pub struct PutBackN { top: Vec, iter: I, diff --git a/src/rciter_impl.rs b/src/rciter_impl.rs index 1282ae865..e3b753206 100644 --- a/src/rciter_impl.rs +++ b/src/rciter_impl.rs @@ -4,6 +4,7 @@ use std::iter::{FusedIterator, IntoIterator}; /// A wrapper for `Rc>`, that implements the `Iterator` trait. #[derive(Debug)] +#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] pub struct RcIter { /// The boxed iterator. pub rciter: Rc>,