From d1e444da4efb50deed02cc907454ea5e817266be Mon Sep 17 00:00:00 2001 From: Ibraheem Ahmed Date: Sat, 19 Feb 2022 14:11:58 -0500 Subject: [PATCH] `impl FromIterator for ()` --- library/core/src/unit.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/library/core/src/unit.rs b/library/core/src/unit.rs index f41f4a5e94a76..aec06e0ddd364 100644 --- a/library/core/src/unit.rs +++ b/library/core/src/unit.rs @@ -1,9 +1,10 @@ use crate::iter::FromIterator; -/// Collapses all unit items from an iterator into one. +/// Drains all items from an iterator. /// -/// This is more useful when combined with higher-level abstractions, like -/// collecting to a `Result<(), E>` where you only care about errors: +/// This is useful to run an iterator to completion when you don't +/// care about the result, or to collect into a `Result<(), E>` when +/// you only care about errors: /// /// ``` /// use std::io::*; @@ -14,8 +15,8 @@ use crate::iter::FromIterator; /// assert!(res.is_ok()); /// ``` #[stable(feature = "unit_from_iter", since = "1.23.0")] -impl FromIterator<()> for () { - fn from_iter>(iter: I) -> Self { - iter.into_iter().for_each(|()| {}) +impl FromIterator for () { + fn from_iter>(iter: A) -> Self { + iter.into_iter().for_each(|_| {}) } }