diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-24 19:45:08 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-24 19:45:08 +0000 |
commit | f16cff3cad931d48a5516b2aec468cfddbed7dd1 (patch) | |
tree | 7daaf3dc8595dc8f431e84db6469c7fa02f6e680 /crates/ra_arena/src | |
parent | 09389ed1d43c244352cecbd78c8685480d60157d (diff) | |
parent | 586acef5283e78f19e5e9daf4e8aac40e2a9ff16 (diff) |
Merge #2393
2393: Simplify ADT fields r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_arena/src')
-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() |