mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Add ModId
This commit is contained in:
parent
902778ccae
commit
4e683d7af1
1 changed files with 17 additions and 8 deletions
|
@ -72,17 +72,26 @@ pub(crate) trait NumericId: Clone + Eq + Hash {
|
|||
fn to_u32(self) -> u32;
|
||||
}
|
||||
|
||||
macro_rules! impl_numeric_id {
|
||||
($id:ident) => {
|
||||
impl NumericId for $id {
|
||||
fn from_u32(id: u32) -> Self {
|
||||
$id(id)
|
||||
}
|
||||
fn to_u32(self) -> u32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub(crate) struct FnId(u32);
|
||||
impl_numeric_id!(FnId);
|
||||
|
||||
impl NumericId for FnId {
|
||||
fn from_u32(id: u32) -> FnId {
|
||||
FnId(id)
|
||||
}
|
||||
fn to_u32(self) -> u32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub(crate) struct ModId(u32);
|
||||
impl_numeric_id!(ModId);
|
||||
|
||||
pub(crate) trait IdDatabase: salsa::Database {
|
||||
fn id_maps(&self) -> &IdMaps;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue