]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/from_iter_instead_of_collect.fixed
Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
[rust.git] / tests / ui / from_iter_instead_of_collect.fixed
index b5f548810e65a8c6dc3bb725ecc81bd5825fc616..48f8093311cbdb41ad7c1700873457cb1154a8be 100644 (file)
@@ -1,10 +1,23 @@
 // run-rustfix
 
 #![warn(clippy::from_iter_instead_of_collect)]
-#![allow(unused_imports)]
+#![allow(unused_imports, unused_tuple_struct_fields)]
 
 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);