Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_macro_utils/src/symbol.rs
6595 views
1
use core::fmt::{self, Display};
2
use syn::{Ident, Path};
3
4
/// A single named value, representable as a [string](str).
5
#[derive(Copy, Clone)]
6
pub struct Symbol(pub &'static str);
7
8
impl PartialEq<Symbol> for Ident {
9
fn eq(&self, word: &Symbol) -> bool {
10
self == word.0
11
}
12
}
13
14
impl<'a> PartialEq<Symbol> for &'a Ident {
15
fn eq(&self, word: &Symbol) -> bool {
16
*self == word.0
17
}
18
}
19
20
impl PartialEq<Symbol> for Path {
21
fn eq(&self, word: &Symbol) -> bool {
22
self.is_ident(word.0)
23
}
24
}
25
26
impl<'a> PartialEq<Symbol> for &'a Path {
27
fn eq(&self, word: &Symbol) -> bool {
28
self.is_ident(word.0)
29
}
30
}
31
32
impl Display for Symbol {
33
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
34
formatter.write_str(self.0)
35
}
36
}
37
38