| commit | 9bcb4c6d0b48553dbe56b891b49b25cc8f53d0ec | [log] [tgz] |
|---|---|---|
| author | David Tolnay <dtolnay@gmail.com> | Sun May 10 17:42:06 2020 -0700 |
| committer | David Tolnay <dtolnay@gmail.com> | Sun May 10 22:57:32 2020 -0700 |
| tree | d9423d4d3de634b0253d84e2a06d873b7d5145e2 | |
| parent | 2b8bf6d262ef6baacd0ededee1b28e7af8266d44 [diff] [blame] |
Extract integer suffix of discriminants as the repr
diff --git a/syntax/atom.rs b/syntax/atom.rs index a2ff7b7..6e5fa88 100644 --- a/syntax/atom.rs +++ b/syntax/atom.rs
@@ -23,8 +23,12 @@ 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),