introduce EnumId
This commit is contained in:
parent
60a607d33f
commit
cefc5cbb4a
@ -15,6 +15,7 @@ pub struct HirInterner {
|
||||
macros: LocationIntener<MacroCallLoc, MacroCallId>,
|
||||
fns: LocationIntener<FunctionLoc, FunctionId>,
|
||||
structs: LocationIntener<StructLoc, StructId>,
|
||||
enums: LocationIntener<EnumLoc, EnumId>,
|
||||
}
|
||||
|
||||
impl HirInterner {
|
||||
@ -213,6 +214,24 @@ pub(crate) fn id(&self, db: &impl AsRef<HirInterner>) -> StructId {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct EnumId(RawId);
|
||||
impl_arena_id!(EnumId);
|
||||
|
||||
pub(crate) type EnumLoc = ItemLoc<ast::EnumDef>;
|
||||
|
||||
impl EnumId {
|
||||
pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> EnumLoc {
|
||||
db.as_ref().enums.id2loc(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl EnumLoc {
|
||||
pub(crate) fn id(&self, db: &impl AsRef<HirInterner>) -> 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)]
|
||||
|
Loading…
Reference in New Issue
Block a user