mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Add helpers for unpacking lang items
This commit is contained in:
parent
523b4cbc60
commit
fc3ab03af7
1 changed files with 44 additions and 0 deletions
|
@ -22,6 +22,50 @@ pub enum LangItemTarget {
|
|||
TraitId(TraitId),
|
||||
}
|
||||
|
||||
impl LangItemTarget {
|
||||
pub fn as_enum(self) -> Option<EnumId> {
|
||||
match self {
|
||||
LangItemTarget::EnumId(id) => Some(id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_function(self) -> Option<FunctionId> {
|
||||
match self {
|
||||
LangItemTarget::FunctionId(id) => Some(id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_impl_block(self) -> Option<ImplId> {
|
||||
match self {
|
||||
LangItemTarget::ImplBlockId(id) => Some(id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_static(self) -> Option<StaticId> {
|
||||
match self {
|
||||
LangItemTarget::StaticId(id) => Some(id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_struct(self) -> Option<StructId> {
|
||||
match self {
|
||||
LangItemTarget::StructId(id) => Some(id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_trait(self) -> Option<TraitId> {
|
||||
match self {
|
||||
LangItemTarget::TraitId(id) => Some(id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct LangItems {
|
||||
items: FxHashMap<SmolStr, LangItemTarget>,
|
||||
|
|
Loading…
Reference in a new issue