blob: 57325d8286a97388345f20c8847c0110e59d7072 [file] [log] [blame]
David Tolnay7db73692019-10-20 14:51:12 -04001use proc_macro2::Ident;
2
3#[derive(Copy, Clone, PartialEq)]
4pub enum Atom {
5 Bool,
6 U8,
7 U16,
8 U32,
9 U64,
10 Usize,
11 I8,
12 I16,
13 I32,
14 I64,
15 Isize,
16 CxxString,
17 RustString,
18}
19
20impl Atom {
21 pub fn from(ident: &Ident) -> Option<Self> {
22 use self::Atom::*;
23 match ident.to_string().as_str() {
24 "bool" => Some(Bool),
25 "u8" => Some(U8),
26 "u16" => Some(U16),
27 "u32" => Some(U32),
28 "u64" => Some(U64),
29 "usize" => Some(Usize),
30 "i8" => Some(I8),
31 "i16" => Some(I16),
32 "i32" => Some(I32),
33 "i64" => Some(I64),
34 "isize" => Some(Isize),
35 "CxxString" => Some(CxxString),
36 "String" => Some(RustString),
37 _ => None,
38 }
39 }
40}