aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_arena/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-25 11:21:14 +0000
committerAleksey Kladov <[email protected]>2019-01-25 11:21:14 +0000
commit87ac5f5b36602922bb45b3a5343010fa305089eb (patch)
tree5a692f559ba36aa5620bf1e7fe2ac0827ad6c25a /crates/ra_arena/src
parent47e553667851bfcdda0317a27c8304dbc9797f32 (diff)
use positional ids for fields
Diffstat (limited to 'crates/ra_arena/src')
-rw-r--r--crates/ra_arena/src/lib.rs13
1 files changed, 13 insertions, 0 deletions
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::{
4 fmt, 4 fmt,
5 marker::PhantomData, 5 marker::PhantomData,
6 ops::{Index, IndexMut}, 6 ops::{Index, IndexMut},
7 iter::FromIterator,
7}; 8};
8 9
9pub mod map; 10pub mod map;
@@ -109,3 +110,15 @@ impl<ID: ArenaId, T> IndexMut<ID> for Arena<ID, T> {
109 &mut self.data[idx] 110 &mut self.data[idx]
110 } 111 }
111} 112}
113
114impl<ID: ArenaId, T> FromIterator<T> for Arena<ID, T> {
115 fn from_iter<I>(iter: I) -> Self
116 where
117 I: IntoIterator<Item = T>,
118 {
119 Arena {
120 data: Vec::from_iter(iter),
121 _ty: PhantomData,
122 }
123 }
124}