mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-08 05:35:22 +00:00
A few more Identifier utilities
This commit is contained in:
parent
5b2af304a2
commit
2af9805662
1 changed files with 22 additions and 1 deletions
|
@ -15,6 +15,13 @@ impl Identifier {
|
|||
}
|
||||
}
|
||||
|
||||
impl Identifier {
|
||||
#[inline]
|
||||
pub fn as_str(&self) -> &str {
|
||||
self.0.as_str()
|
||||
}
|
||||
}
|
||||
|
||||
impl std::cmp::PartialEq<str> for Identifier {
|
||||
#[inline]
|
||||
fn eq(&self, other: &str) -> bool {
|
||||
|
@ -30,9 +37,23 @@ impl std::cmp::PartialEq<String> for Identifier {
|
|||
}
|
||||
|
||||
impl std::ops::Deref for Identifier {
|
||||
type Target = String;
|
||||
type Target = str;
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.0.as_str()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<str> for Identifier {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &str {
|
||||
self.0.as_str()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<String> for Identifier {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &String {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue