1 use std::fmt::{self, Display};
2 use syn::{Ident, Path};
3 
4 #[derive(Copy, Clone)]
5 pub struct Symbol(&'static str);
6 
7 pub const ALIAS: Symbol = Symbol("alias");
8 pub const BORROW: Symbol = Symbol("borrow");
9 pub const BOUND: Symbol = Symbol("bound");
10 pub const CONTENT: Symbol = Symbol("content");
11 pub const CRATE: Symbol = Symbol("crate");
12 pub const DEFAULT: Symbol = Symbol("default");
13 pub const DENY_UNKNOWN_FIELDS: Symbol = Symbol("deny_unknown_fields");
14 pub const DESERIALIZE: Symbol = Symbol("deserialize");
15 pub const DESERIALIZE_WITH: Symbol = Symbol("deserialize_with");
16 pub const FIELD_IDENTIFIER: Symbol = Symbol("field_identifier");
17 pub const FLATTEN: Symbol = Symbol("flatten");
18 pub const FROM: Symbol = Symbol("from");
19 pub const GETTER: Symbol = Symbol("getter");
20 pub const INTO: Symbol = Symbol("into");
21 pub const OTHER: Symbol = Symbol("other");
22 pub const REMOTE: Symbol = Symbol("remote");
23 pub const RENAME: Symbol = Symbol("rename");
24 pub const RENAME_ALL: Symbol = Symbol("rename_all");
25 pub const SERDE: Symbol = Symbol("serde");
26 pub const SERIALIZE: Symbol = Symbol("serialize");
27 pub const SERIALIZE_WITH: Symbol = Symbol("serialize_with");
28 pub const SKIP: Symbol = Symbol("skip");
29 pub const SKIP_DESERIALIZING: Symbol = Symbol("skip_deserializing");
30 pub const SKIP_SERIALIZING: Symbol = Symbol("skip_serializing");
31 pub const SKIP_SERIALIZING_IF: Symbol = Symbol("skip_serializing_if");
32 pub const TAG: Symbol = Symbol("tag");
33 pub const TRANSPARENT: Symbol = Symbol("transparent");
34 pub const TRY_FROM: Symbol = Symbol("try_from");
35 pub const UNTAGGED: Symbol = Symbol("untagged");
36 pub const VARIANT_IDENTIFIER: Symbol = Symbol("variant_identifier");
37 pub const WITH: Symbol = Symbol("with");
38 pub const EXPECTING: Symbol = Symbol("expecting");
39 
40 impl PartialEq<Symbol> for Ident {
eq(&self, word: &Symbol) -> bool41     fn eq(&self, word: &Symbol) -> bool {
42         self == word.0
43     }
44 }
45 
46 impl<'a> PartialEq<Symbol> for &'a Ident {
eq(&self, word: &Symbol) -> bool47     fn eq(&self, word: &Symbol) -> bool {
48         *self == word.0
49     }
50 }
51 
52 impl PartialEq<Symbol> for Path {
eq(&self, word: &Symbol) -> bool53     fn eq(&self, word: &Symbol) -> bool {
54         self.is_ident(word.0)
55     }
56 }
57 
58 impl<'a> PartialEq<Symbol> for &'a Path {
eq(&self, word: &Symbol) -> bool59     fn eq(&self, word: &Symbol) -> bool {
60         self.is_ident(word.0)
61     }
62 }
63 
64 impl Display for Symbol {
fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result65     fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
66         formatter.write_str(self.0)
67     }
68 }
69