1
Fork 0

Add lint against Iterator::map receiving a callable that returns ()

This commit is contained in:
Obei Sideg 2023-02-16 22:04:59 +03:00
parent 8b1dbf728a
commit a914f37409
6 changed files with 134 additions and 1 deletions

View file

@ -278,6 +278,7 @@
//!
//! ```
//! # #![allow(unused_must_use)]
//! # #![cfg_attr(not(bootstrap), allow(map_unit_fn))]
//! let v = vec![1, 2, 3, 4, 5];
//! v.iter().map(|x| println!("{x}"));
//! ```

View file

@ -777,6 +777,7 @@ pub trait Iterator {
/// println!("{x}");
/// }
/// ```
#[rustc_diagnostic_item = "IteratorMap"]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn map<B, F>(self, f: F) -> Map<Self, F>