From 87ac5f5b36602922bb45b3a5343010fa305089eb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 25 Jan 2019 14:21:14 +0300 Subject: use positional ids for fields --- crates/ra_arena/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'crates/ra_arena') diff --git a/crates/ra_arena/src/lib.rs b/crates/ra_arena/src/lib.rs index d7d5d5265..97f554838 100644 --- a/crates/ra_arena/src/lib.rs +++ b/crates/ra_arena/src/lib.rs @@ -4,6 +4,7 @@ use std::{ fmt, marker::PhantomData, ops::{Index, IndexMut}, + iter::FromIterator, }; pub mod map; @@ -109,3 +110,15 @@ impl IndexMut for Arena { &mut self.data[idx] } } + +impl FromIterator for Arena { + fn from_iter(iter: I) -> Self + where + I: IntoIterator, + { + Arena { + data: Vec::from_iter(iter), + _ty: PhantomData, + } + } +} -- cgit v1.2.3