From c57a8579888643e73e12dd0ca23e81f88608c52f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 24 Jan 2019 16:18:20 +0300 Subject: add StructId --- crates/ra_hir/src/ids.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crates') diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index f00448081..51e3cfb81 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -14,6 +14,7 @@ pub struct HirInterner { defs: LocationIntener, macros: LocationIntener, fns: LocationIntener, + structs: LocationIntener, } impl HirInterner { @@ -194,6 +195,24 @@ impl FunctionLoc { } } +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct StructId(RawId); +impl_arena_id!(StructId); + +pub(crate) type StructLoc = ItemLoc; + +impl StructId { + pub(crate) fn loc(self, db: &impl AsRef) -> StructLoc { + db.as_ref().structs.id2loc(self) + } +} + +impl StructLoc { + pub(crate) fn id(&self, db: &impl AsRef) -> StructId { + db.as_ref().structs.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