diff options
Diffstat (limited to 'crates/ra_parser/src/syntax_kind.rs')
-rw-r--r-- | crates/ra_parser/src/syntax_kind.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_parser/src/syntax_kind.rs b/crates/ra_parser/src/syntax_kind.rs index 00faa7799..3efcfa403 100644 --- a/crates/ra_parser/src/syntax_kind.rs +++ b/crates/ra_parser/src/syntax_kind.rs | |||
@@ -1,19 +1,19 @@ | |||
1 | #[macro_use] | 1 | #[macro_use] |
2 | mod generated; | 2 | mod generated; |
3 | 3 | ||
4 | use std::fmt; | ||
5 | |||
6 | pub use self::generated::SyntaxKind; | 4 | pub use self::generated::SyntaxKind; |
7 | 5 | ||
8 | impl fmt::Debug for SyntaxKind { | 6 | impl From<u16> for SyntaxKind { |
9 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | 7 | fn from(d: u16) -> SyntaxKind { |
10 | let name = self.info().name; | 8 | assert!(d <= (SyntaxKind::__LAST as u16)); |
11 | f.write_str(name) | 9 | unsafe { std::mem::transmute::<u16, SyntaxKind>(d) } |
12 | } | 10 | } |
13 | } | 11 | } |
14 | 12 | ||
15 | pub(crate) struct SyntaxInfo { | 13 | impl From<SyntaxKind> for u16 { |
16 | pub name: &'static str, | 14 | fn from(k: SyntaxKind) -> u16 { |
15 | k as u16 | ||
16 | } | ||
17 | } | 17 | } |
18 | 18 | ||
19 | impl SyntaxKind { | 19 | impl SyntaxKind { |