annotation_rs_helpers/
symbol.rs1use std::fmt::{self, Display};
2use syn::{Ident, Path};
3
4#[derive(Copy, Clone)]
5pub struct Symbol(&'static str);
6
7impl Symbol {
8 pub fn new(path: &'static str) -> Self {
9 Symbol(path)
10 }
11}
12
13impl PartialEq<Symbol> for Ident {
14 fn eq(&self, word: &Symbol) -> bool {
15 self == word.0
16 }
17}
18
19impl<'a> PartialEq<Symbol> for &'a Ident {
20 fn eq(&self, word: &Symbol) -> bool {
21 *self == word.0
22 }
23}
24
25impl PartialEq<Symbol> for Path {
26 fn eq(&self, word: &Symbol) -> bool {
27 self.is_ident(word.0)
28 }
29}
30
31impl<'a> PartialEq<Symbol> for &'a Path {
32 fn eq(&self, word: &Symbol) -> bool {
33 self.is_ident(word.0)
34 }
35}
36
37impl Display for Symbol {
38 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
39 formatter.write_str(self.0)
40 }
41}