| 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 EXPECTING: Symbol = Symbol("expecting" ); |
| 17 | pub const FIELD_IDENTIFIER: Symbol = Symbol("field_identifier" ); |
| 18 | pub const FLATTEN: Symbol = Symbol("flatten" ); |
| 19 | pub const FROM: Symbol = Symbol("from" ); |
| 20 | pub const GETTER: Symbol = Symbol("getter" ); |
| 21 | pub const INTO: Symbol = Symbol("into" ); |
| 22 | pub const NON_EXHAUSTIVE: Symbol = Symbol("non_exhaustive" ); |
| 23 | pub const OTHER: Symbol = Symbol("other" ); |
| 24 | pub const REMOTE: Symbol = Symbol("remote" ); |
| 25 | pub const RENAME: Symbol = Symbol("rename" ); |
| 26 | pub const RENAME_ALL: Symbol = Symbol("rename_all" ); |
| 27 | pub const RENAME_ALL_FIELDS: Symbol = Symbol("rename_all_fields" ); |
| 28 | pub const REPR: Symbol = Symbol("repr" ); |
| 29 | pub const SERDE: Symbol = Symbol("serde" ); |
| 30 | pub const SERIALIZE: Symbol = Symbol("serialize" ); |
| 31 | pub const SERIALIZE_WITH: Symbol = Symbol("serialize_with" ); |
| 32 | pub const SKIP: Symbol = Symbol("skip" ); |
| 33 | pub const SKIP_DESERIALIZING: Symbol = Symbol("skip_deserializing" ); |
| 34 | pub const SKIP_SERIALIZING: Symbol = Symbol("skip_serializing" ); |
| 35 | pub const SKIP_SERIALIZING_IF: Symbol = Symbol("skip_serializing_if" ); |
| 36 | pub const TAG: Symbol = Symbol("tag" ); |
| 37 | pub const TRANSPARENT: Symbol = Symbol("transparent" ); |
| 38 | pub const TRY_FROM: Symbol = Symbol("try_from" ); |
| 39 | pub const UNTAGGED: Symbol = Symbol("untagged" ); |
| 40 | pub const VARIANT_IDENTIFIER: Symbol = Symbol("variant_identifier" ); |
| 41 | pub const WITH: Symbol = Symbol("with" ); |
| 42 | |
| 43 | impl PartialEq<Symbol> for Ident { |
| 44 | fn eq(&self, word: &Symbol) -> bool { |
| 45 | self == word.0 |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | impl PartialEq<Symbol> for &Ident { |
| 50 | fn eq(&self, word: &Symbol) -> bool { |
| 51 | *self == word.0 |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | impl PartialEq<Symbol> for Path { |
| 56 | fn eq(&self, word: &Symbol) -> bool { |
| 57 | self.is_ident(word.0) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | impl PartialEq<Symbol> for &Path { |
| 62 | fn eq(&self, word: &Symbol) -> bool { |
| 63 | self.is_ident(word.0) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | impl Display for Symbol { |
| 68 | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
| 69 | formatter.write_str(self.0) |
| 70 | } |
| 71 | } |
| 72 | |