Construct AssociatedItems
from an iterator instead of a Vec
This commit is contained in:
parent
186cbfad89
commit
a0212ba40f
@ -277,7 +277,7 @@ pub struct AssociatedItems {
|
||||
|
||||
impl AssociatedItems {
|
||||
/// Constructs an `AssociatedItems` map from a series of `ty::AssocItem`s in definition order.
|
||||
pub fn new(items_in_def_order: Vec<ty::AssocItem>) -> Self {
|
||||
pub fn new(items_in_def_order: impl IntoIterator<Item = ty::AssocItem>) -> Self {
|
||||
let items = items_in_def_order.into_iter().map(|item| (item.ident.name, item)).collect();
|
||||
AssociatedItems { items }
|
||||
}
|
||||
|
@ -211,8 +211,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
|
||||
}
|
||||
|
||||
fn associated_items<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::AssociatedItems {
|
||||
let items =
|
||||
tcx.associated_item_def_ids(def_id).iter().map(|did| tcx.associated_item(*did)).collect();
|
||||
let items = tcx.associated_item_def_ids(def_id).iter().map(|did| tcx.associated_item(*did));
|
||||
tcx.arena.alloc(ty::AssociatedItems::new(items))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user