mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-12 15:45:22 +00:00
Merge pull request #19 from RustPython/identifier
A few more Identifier utilities
This commit is contained in:
commit
2baad9ead6
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 {
|
impl std::cmp::PartialEq<str> for Identifier {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &str) -> bool {
|
fn eq(&self, other: &str) -> bool {
|
||||||
|
@ -30,9 +37,23 @@ impl std::cmp::PartialEq<String> for Identifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::ops::Deref for Identifier {
|
impl std::ops::Deref for Identifier {
|
||||||
type Target = String;
|
type Target = str;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deref(&self) -> &Self::Target {
|
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
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue