diff options
| author | Miguel Guarniz <mi9uel9@gmail.com> | 2022-04-09 13:56:56 -0400 |
|---|---|---|
| committer | Miguel Guarniz <mi9uel9@gmail.com> | 2022-04-09 13:56:56 -0400 |
| commit | f983d2658ba88e1ef2a0f21fbeef842a91d49d1b (patch) | |
| tree | 8d20bbe69a51ae3887727804fdb1f3fc8eb73c4a | |
| parent | 51ee3d4d9207e1fd7079074425c6985632ff43d6 (diff) | |
| download | rust-f983d2658ba88e1ef2a0f21fbeef842a91d49d1b.tar.gz rust-f983d2658ba88e1ef2a0f21fbeef842a91d49d1b.zip | |
use copied() and avoid creating a vector in items and par_items
| -rw-r--r-- | compiler/rustc_middle/src/hir/mod.rs | 19 |
1 files 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<Item = ItemId> { - self.items.to_vec().into_iter() + pub fn items(&self) -> impl Iterator<Item = ItemId> + '_ { + self.items.iter().copied() } - pub fn trait_items(&self) -> impl Iterator<Item = TraitItemId> { - self.trait_items.to_vec().into_iter() + + pub fn trait_items(&self) -> impl Iterator<Item = TraitItemId> + '_ { + self.trait_items.iter().copied() } - pub fn impl_items(&self) -> impl Iterator<Item = ImplItemId> { - self.impl_items.to_vec().into_iter() + + pub fn impl_items(&self) -> impl Iterator<Item = ImplItemId> + '_ { + self.impl_items.iter().copied() } - pub fn foreign_items(&self) -> impl Iterator<Item = ForeignItemId> { - self.foreign_items.to_vec().into_iter() + + pub fn foreign_items(&self) -> impl Iterator<Item = ForeignItemId> + '_ { + self.foreign_items.iter().copied() } } |
