use copied() and avoid creating a vector in items and par_items

This commit is contained in:
Miguel Guarniz 2022-04-09 13:56:56 -04:00
parent 51ee3d4d92
commit f983d2658b

View File

@ -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()
}
}