diff options
author | Aleksey Kladov <[email protected]> | 2019-11-24 19:44:24 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-24 19:44:24 +0000 |
commit | 586acef5283e78f19e5e9daf4e8aac40e2a9ff16 (patch) | |
tree | 7daaf3dc8595dc8f431e84db6469c7fa02f6e680 /crates/ra_arena | |
parent | 09389ed1d43c244352cecbd78c8685480d60157d (diff) |
Simplify ADT fields
Diffstat (limited to 'crates/ra_arena')
-rw-r--r-- | crates/ra_arena/src/lib.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_arena/src/lib.rs b/crates/ra_arena/src/lib.rs index 3ec8d3b60..984e1eec3 100644 --- a/crates/ra_arena/src/lib.rs +++ b/crates/ra_arena/src/lib.rs | |||
@@ -37,7 +37,7 @@ impl fmt::Display for RawId { | |||
37 | } | 37 | } |
38 | 38 | ||
39 | #[derive(Clone, PartialEq, Eq)] | 39 | #[derive(Clone, PartialEq, Eq)] |
40 | pub struct Arena<ID: ArenaId, T> { | 40 | pub struct Arena<ID, T> { |
41 | data: Vec<T>, | 41 | data: Vec<T>, |
42 | _ty: PhantomData<ID>, | 42 | _ty: PhantomData<ID>, |
43 | } | 43 | } |
@@ -67,6 +67,12 @@ pub trait ArenaId { | |||
67 | fn into_raw(self) -> RawId; | 67 | fn into_raw(self) -> RawId; |
68 | } | 68 | } |
69 | 69 | ||
70 | impl<ID, T> Arena<ID, T> { | ||
71 | pub const fn new() -> Arena<ID, T> { | ||
72 | Arena { data: Vec::new(), _ty: PhantomData } | ||
73 | } | ||
74 | } | ||
75 | |||
70 | impl<ID: ArenaId, T> Arena<ID, T> { | 76 | impl<ID: ArenaId, T> Arena<ID, T> { |
71 | pub fn len(&self) -> usize { | 77 | pub fn len(&self) -> usize { |
72 | self.data.len() | 78 | self.data.len() |