Merge pull request #19 from RustPython/identifier

A few more Identifier utilities
This commit is contained in:
Jeong, YunWon 2023-05-11 16:12:46 +09:00 committed by GitHub
commit 2baad9ead6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}
}