2024-09-27 00:59:59 +00:00
|
|
|
use core::fmt::{self, Display};
|
2021-10-03 19:23:44 +00:00
|
|
|
use syn::{Ident, Path};
|
|
|
|
|
2023-10-02 00:22:57 +00:00
|
|
|
/// A single named value, representable as a [string](str).
|
2021-10-03 19:23:44 +00:00
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
pub struct Symbol(pub &'static str);
|
|
|
|
|
|
|
|
impl PartialEq<Symbol> for Ident {
|
|
|
|
fn eq(&self, word: &Symbol) -> bool {
|
|
|
|
self == word.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> PartialEq<Symbol> for &'a Ident {
|
|
|
|
fn eq(&self, word: &Symbol) -> bool {
|
|
|
|
*self == word.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialEq<Symbol> for Path {
|
|
|
|
fn eq(&self, word: &Symbol) -> bool {
|
|
|
|
self.is_ident(word.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> PartialEq<Symbol> for &'a Path {
|
|
|
|
fn eq(&self, word: &Symbol) -> bool {
|
|
|
|
self.is_ident(word.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Display for Symbol {
|
|
|
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
formatter.write_str(self.0)
|
|
|
|
}
|
|
|
|
}
|