blob: 2bbdc069aa0fcd7d2ab35a28130d89877988f1a7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
use std::fmt;
use syn::Path;
#[derive(Copy, Clone)]
pub struct Symbol(&'static str);
pub const NIX: Symbol = Symbol("nix");
pub const VERSION: Symbol = Symbol("version");
pub const DEFAULT: Symbol = Symbol("default");
pub const FROM: Symbol = Symbol("from");
pub const TRY_FROM: Symbol = Symbol("try_from");
pub const FROM_STR: Symbol = Symbol("from_str");
pub const INTO: Symbol = Symbol("into");
pub const TRY_INTO: Symbol = Symbol("try_into");
pub const DISPLAY: Symbol = Symbol("display");
pub const CRATE: Symbol = Symbol("crate");
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 fmt::Display for Symbol {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str(self.0)
}
}
|