From cefc5cbb4a95d2a473ea656efe603bef979b5c49 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 24 Jan 2019 17:56:00 +0300 Subject: introduce EnumId --- crates/ra_hir/src/ids.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 2791149dd..530fdf5cd 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -15,6 +15,7 @@ pub struct HirInterner { macros: LocationIntener, fns: LocationIntener, structs: LocationIntener, + enums: LocationIntener, } impl HirInterner { @@ -213,6 +214,24 @@ impl StructLoc { } } +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct EnumId(RawId); +impl_arena_id!(EnumId); + +pub(crate) type EnumLoc = ItemLoc; + +impl EnumId { + pub(crate) fn loc(self, db: &impl AsRef) -> EnumLoc { + db.as_ref().enums.id2loc(self) + } +} + +impl EnumLoc { + pub(crate) fn id(&self, db: &impl AsRef) -> EnumId { + db.as_ref().enums.loc2id(&self) + } +} + /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) /// in a specific module. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -- cgit v1.2.3