aboutsummaryrefslogtreecommitdiff
path: root/syntax/atom.rs
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2020-05-10 17:42:06 -0700
committerDavid Tolnay <dtolnay@gmail.com>2020-05-10 22:57:32 -0700
commit9bcb4c6d0b48553dbe56b891b49b25cc8f53d0ec (patch)
treed9423d4d3de634b0253d84e2a06d873b7d5145e2 /syntax/atom.rs
parent2b8bf6d262ef6baacd0ededee1b28e7af8266d44 (diff)
downloadcxx-9bcb4c6d0b48553dbe56b891b49b25cc8f53d0ec.tar.gz
Extract integer suffix of discriminants as the repr
Diffstat (limited to 'syntax/atom.rs')
-rw-r--r--syntax/atom.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/syntax/atom.rs b/syntax/atom.rs
index a2ff7b7f..6e5fa880 100644
--- a/syntax/atom.rs
+++ b/syntax/atom.rs
@@ -23,8 +23,12 @@ pub enum Atom {
impl Atom {
pub fn from(ident: &Ident) -> Option<Self> {
+ Self::from_str(ident.to_string().as_str())
+ }
+
+ pub fn from_str(s: &str) -> Option<Self> {
use self::Atom::*;
- match ident.to_string().as_str() {
+ match s {
"bool" => Some(Bool),
"u8" => Some(U8),
"u16" => Some(U16),