summaryrefslogtreecommitdiff
path: root/src/syntax/ident.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/syntax/ident.rs')
-rw-r--r--src/syntax/ident.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/syntax/ident.rs b/src/syntax/ident.rs
index c47e6fb1..398e2ff9 100644
--- a/src/syntax/ident.rs
+++ b/src/syntax/ident.rs
@@ -1,3 +1,4 @@
+use std::borrow::Borrow;
use std::ops::Deref;
use unicode_xid::UnicodeXID;
@@ -53,6 +54,18 @@ impl AsRef<str> for Ident {
}
}
+impl Borrow<str> for Ident {
+ fn borrow(&self) -> &str {
+ self
+ }
+}
+
+impl From<&Ident> for EcoString {
+ fn from(ident: &Ident) -> Self {
+ ident.string.clone()
+ }
+}
+
/// Whether a string is a valid identifier.
pub fn is_ident(string: &str) -> bool {
let mut chars = string.chars();