diff --git a/library/core/src/iter/traits/collect.rs b/library/core/src/iter/traits/collect.rs index 637d7bc44885e..6eabf08cd4bed 100644 --- a/library/core/src/iter/traits/collect.rs +++ b/library/core/src/iter/traits/collect.rs @@ -374,11 +374,11 @@ pub trait Extend { } #[stable(feature = "extend_for_unit", since = "1.28.0")] -impl Extend<()> for () { - fn extend>(&mut self, iter: T) { +impl Extend for () { + fn extend>(&mut self, iter: A) { iter.into_iter().for_each(drop) } - fn extend_one(&mut self, _item: ()) {} + fn extend_one(&mut self, _item: T) {} } #[stable(feature = "extend_for_tuple", since = "1.56.0")] 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(|_| {}) } }