]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/from_iter_instead_of_collect.fixed
Use the traits added to the Rust 2021 Edition prelude
[rust.git] / tests / ui / from_iter_instead_of_collect.fixed
index b5f548810e65a8c6dc3bb725ecc81bd5825fc616..403c3b3e44380ef3a971ab36504d48b2bd0537bb 100644 (file)
@@ -4,7 +4,20 @@
 #![allow(unused_imports)]
 
 use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque};
-use std::iter::FromIterator;
+
+struct Foo(Vec<bool>);
+
+impl FromIterator<bool> for Foo {
+    fn from_iter<T: IntoIterator<Item = bool>>(_: T) -> Self {
+        todo!()
+    }
+}
+
+impl<'a> FromIterator<&'a bool> for Foo {
+    fn from_iter<T: IntoIterator<Item = &'a bool>>(iter: T) -> Self {
+        iter.into_iter().copied().collect::<Self>()
+    }
+}
 
 fn main() {
     let iter_expr = std::iter::repeat(5).take(5);