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