From f983d2658ba88e1ef2a0f21fbeef842a91d49d1b Mon Sep 17 00:00:00 2001 From: Miguel Guarniz Date: Sat, 9 Apr 2022 13:56:56 -0400 Subject: [PATCH] use copied() and avoid creating a vector in items and par_items --- compiler/rustc_middle/src/hir/mod.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index 039e9953814..f18067145dd 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -46,17 +46,20 @@ pub struct ModuleItems { } impl ModuleItems { - pub fn items(&self) -> impl Iterator { - self.items.to_vec().into_iter() + pub fn items(&self) -> impl Iterator + '_ { + self.items.iter().copied() } - pub fn trait_items(&self) -> impl Iterator { - self.trait_items.to_vec().into_iter() + + pub fn trait_items(&self) -> impl Iterator + '_ { + self.trait_items.iter().copied() } - pub fn impl_items(&self) -> impl Iterator { - self.impl_items.to_vec().into_iter() + + pub fn impl_items(&self) -> impl Iterator + '_ { + self.impl_items.iter().copied() } - pub fn foreign_items(&self) -> impl Iterator { - self.foreign_items.to_vec().into_iter() + + pub fn foreign_items(&self) -> impl Iterator + '_ { + self.foreign_items.iter().copied() } }