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