1/// Collapses all unit items from an iterator into one.
2///
3/// This is more useful when combined with higher-level abstractions, like
4/// collecting to a `Result<(), E>` where you only care about errors:
5///
6/// ```
7/// use std::io::*;
8/// let data = vec![1, 2, 3, 4, 5];
9/// let res: Result<()> = data.iter()
10/// .map(|x| writeln!(stdout(), "{x}"))
11/// .collect();
12/// assert!(res.is_ok());
13/// ```
14#[stable(feature = "unit_from_iter", since = "1.23.0")]
15impl FromIterator<()> for () {
16 fn from_iter<I: IntoIterator<Item = ()>>(iter: I) -> Self {
17 iter.into_iter().for_each(|()| {})
18 }
19}
20