diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-11-06 18:10:17 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-06 18:10:17 +0000 |
commit | 0d5be44b6e0ccd3e806697dcfc2337a2c0ed5914 (patch) | |
tree | 1f048935ea6b51cc1e5f01d0613552264b31f02d /crates/syntax/src/ast/generated | |
parent | 2c408c68a4a27e9a85ce85ec1342e3af58c1571f (diff) | |
parent | eb460333907a44c37bf7287b31c653877c3358c2 (diff) |
Merge #6482
6482: More orthogonal API r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/syntax/src/ast/generated')
-rw-r--r-- | crates/syntax/src/ast/generated/tokens.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/crates/syntax/src/ast/generated/tokens.rs b/crates/syntax/src/ast/generated/tokens.rs index abadd0b61..1b8449221 100644 --- a/crates/syntax/src/ast/generated/tokens.rs +++ b/crates/syntax/src/ast/generated/tokens.rs | |||
@@ -89,3 +89,45 @@ impl AstToken for RawString { | |||
89 | } | 89 | } |
90 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | 90 | fn syntax(&self) -> &SyntaxToken { &self.syntax } |
91 | } | 91 | } |
92 | |||
93 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
94 | pub struct IntNumber { | ||
95 | pub(crate) syntax: SyntaxToken, | ||
96 | } | ||
97 | impl std::fmt::Display for IntNumber { | ||
98 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
99 | std::fmt::Display::fmt(&self.syntax, f) | ||
100 | } | ||
101 | } | ||
102 | impl AstToken for IntNumber { | ||
103 | fn can_cast(kind: SyntaxKind) -> bool { kind == INT_NUMBER } | ||
104 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
105 | if Self::can_cast(syntax.kind()) { | ||
106 | Some(Self { syntax }) | ||
107 | } else { | ||
108 | None | ||
109 | } | ||
110 | } | ||
111 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
112 | } | ||
113 | |||
114 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
115 | pub struct FloatNumber { | ||
116 | pub(crate) syntax: SyntaxToken, | ||
117 | } | ||
118 | impl std::fmt::Display for FloatNumber { | ||
119 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
120 | std::fmt::Display::fmt(&self.syntax, f) | ||
121 | } | ||
122 | } | ||
123 | impl AstToken for FloatNumber { | ||
124 | fn can_cast(kind: SyntaxKind) -> bool { kind == FLOAT_NUMBER } | ||
125 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
126 | if Self::can_cast(syntax.kind()) { | ||
127 | Some(Self { syntax }) | ||
128 | } else { | ||
129 | None | ||
130 | } | ||
131 | } | ||
132 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
133 | } | ||