aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_arena/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-24 19:45:08 +0000
committerGitHub <[email protected]>2019-11-24 19:45:08 +0000
commitf16cff3cad931d48a5516b2aec468cfddbed7dd1 (patch)
tree7daaf3dc8595dc8f431e84db6469c7fa02f6e680 /crates/ra_arena/src/lib.rs
parent09389ed1d43c244352cecbd78c8685480d60157d (diff)
parent586acef5283e78f19e5e9daf4e8aac40e2a9ff16 (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/lib.rs')
-rw-r--r--crates/ra_arena/src/lib.rs8
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)]
40pub struct Arena<ID: ArenaId, T> { 40pub 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
70impl<ID, T> Arena<ID, T> {
71 pub const fn new() -> Arena<ID, T> {
72 Arena { data: Vec::new(), _ty: PhantomData }
73 }
74}
75
70impl<ID: ArenaId, T> Arena<ID, T> { 76impl<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()