aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-04-09 15:17:18 +0100
committerAleksey Kladov <[email protected]>2020-04-09 15:17:18 +0100
commitd61932ef7e74f3d9f7863c33c6647c2c52538ed5 (patch)
treed8f52aafe87bbc34e09fe9c181369a5523097b2b
parent0fc8c5cca01501b3b6b708b0ba9ba94c0a81f69e (diff)
Prepare for spliting generated into tokens and nodes
-rw-r--r--crates/ra_syntax/src/ast.rs2
-rw-r--r--crates/ra_syntax/src/ast/generated.rs9626
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs9625
-rw-r--r--xtask/src/codegen.rs2
-rw-r--r--xtask/src/codegen/gen_syntax.rs2
5 files changed, 9630 insertions, 9627 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index e1ebd5b92..9da44e251 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -21,7 +21,7 @@ pub use self::{
21 AttrKind, FieldKind, PathSegmentKind, SelfParamKind, SlicePatComponents, StructKind, 21 AttrKind, FieldKind, PathSegmentKind, SelfParamKind, SlicePatComponents, StructKind,
22 TypeBoundKind, VisibilityKind, 22 TypeBoundKind, VisibilityKind,
23 }, 23 },
24 generated::*, 24 generated::nodes::*,
25 tokens::*, 25 tokens::*,
26 traits::*, 26 traits::*,
27}; 27};
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index bd92e9c87..6216641d8 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -1,9625 +1,3 @@
1//! Generated file, do not edit by hand, see `xtask/src/codegen` 1//! This file is actually hand-written, but the submodules are indeed generated.
2 2
3#[allow(unused_imports)] 3pub(super) mod nodes;
4use crate::{
5 ast::{self, support, AstChildren, AstNode, AstToken},
6 NodeOrToken, SyntaxElement,
7 SyntaxKind::{self, *},
8 SyntaxNode, SyntaxToken,
9};
10#[derive(Debug, Clone, PartialEq, Eq, Hash)]
11pub struct Semi {
12 pub(crate) syntax: SyntaxToken,
13}
14impl std::fmt::Display for Semi {
15 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
16 std::fmt::Display::fmt(&self.syntax, f)
17 }
18}
19impl AstToken for Semi {
20 fn can_cast(kind: SyntaxKind) -> bool {
21 match kind {
22 SEMI => true,
23 _ => false,
24 }
25 }
26 fn cast(syntax: SyntaxToken) -> Option<Self> {
27 if Self::can_cast(syntax.kind()) {
28 Some(Self { syntax })
29 } else {
30 None
31 }
32 }
33 fn syntax(&self) -> &SyntaxToken {
34 &self.syntax
35 }
36}
37#[derive(Debug, Clone, PartialEq, Eq, Hash)]
38pub struct Comma {
39 pub(crate) syntax: SyntaxToken,
40}
41impl std::fmt::Display for Comma {
42 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
43 std::fmt::Display::fmt(&self.syntax, f)
44 }
45}
46impl AstToken for Comma {
47 fn can_cast(kind: SyntaxKind) -> bool {
48 match kind {
49 COMMA => true,
50 _ => false,
51 }
52 }
53 fn cast(syntax: SyntaxToken) -> Option<Self> {
54 if Self::can_cast(syntax.kind()) {
55 Some(Self { syntax })
56 } else {
57 None
58 }
59 }
60 fn syntax(&self) -> &SyntaxToken {
61 &self.syntax
62 }
63}
64#[derive(Debug, Clone, PartialEq, Eq, Hash)]
65pub struct LParen {
66 pub(crate) syntax: SyntaxToken,
67}
68impl std::fmt::Display for LParen {
69 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
70 std::fmt::Display::fmt(&self.syntax, f)
71 }
72}
73impl AstToken for LParen {
74 fn can_cast(kind: SyntaxKind) -> bool {
75 match kind {
76 L_PAREN => true,
77 _ => false,
78 }
79 }
80 fn cast(syntax: SyntaxToken) -> Option<Self> {
81 if Self::can_cast(syntax.kind()) {
82 Some(Self { syntax })
83 } else {
84 None
85 }
86 }
87 fn syntax(&self) -> &SyntaxToken {
88 &self.syntax
89 }
90}
91#[derive(Debug, Clone, PartialEq, Eq, Hash)]
92pub struct RParen {
93 pub(crate) syntax: SyntaxToken,
94}
95impl std::fmt::Display for RParen {
96 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
97 std::fmt::Display::fmt(&self.syntax, f)
98 }
99}
100impl AstToken for RParen {
101 fn can_cast(kind: SyntaxKind) -> bool {
102 match kind {
103 R_PAREN => true,
104 _ => false,
105 }
106 }
107 fn cast(syntax: SyntaxToken) -> Option<Self> {
108 if Self::can_cast(syntax.kind()) {
109 Some(Self { syntax })
110 } else {
111 None
112 }
113 }
114 fn syntax(&self) -> &SyntaxToken {
115 &self.syntax
116 }
117}
118#[derive(Debug, Clone, PartialEq, Eq, Hash)]
119pub struct LCurly {
120 pub(crate) syntax: SyntaxToken,
121}
122impl std::fmt::Display for LCurly {
123 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
124 std::fmt::Display::fmt(&self.syntax, f)
125 }
126}
127impl AstToken for LCurly {
128 fn can_cast(kind: SyntaxKind) -> bool {
129 match kind {
130 L_CURLY => true,
131 _ => false,
132 }
133 }
134 fn cast(syntax: SyntaxToken) -> Option<Self> {
135 if Self::can_cast(syntax.kind()) {
136 Some(Self { syntax })
137 } else {
138 None
139 }
140 }
141 fn syntax(&self) -> &SyntaxToken {
142 &self.syntax
143 }
144}
145#[derive(Debug, Clone, PartialEq, Eq, Hash)]
146pub struct RCurly {
147 pub(crate) syntax: SyntaxToken,
148}
149impl std::fmt::Display for RCurly {
150 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
151 std::fmt::Display::fmt(&self.syntax, f)
152 }
153}
154impl AstToken for RCurly {
155 fn can_cast(kind: SyntaxKind) -> bool {
156 match kind {
157 R_CURLY => true,
158 _ => false,
159 }
160 }
161 fn cast(syntax: SyntaxToken) -> Option<Self> {
162 if Self::can_cast(syntax.kind()) {
163 Some(Self { syntax })
164 } else {
165 None
166 }
167 }
168 fn syntax(&self) -> &SyntaxToken {
169 &self.syntax
170 }
171}
172#[derive(Debug, Clone, PartialEq, Eq, Hash)]
173pub struct LBrack {
174 pub(crate) syntax: SyntaxToken,
175}
176impl std::fmt::Display for LBrack {
177 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
178 std::fmt::Display::fmt(&self.syntax, f)
179 }
180}
181impl AstToken for LBrack {
182 fn can_cast(kind: SyntaxKind) -> bool {
183 match kind {
184 L_BRACK => true,
185 _ => false,
186 }
187 }
188 fn cast(syntax: SyntaxToken) -> Option<Self> {
189 if Self::can_cast(syntax.kind()) {
190 Some(Self { syntax })
191 } else {
192 None
193 }
194 }
195 fn syntax(&self) -> &SyntaxToken {
196 &self.syntax
197 }
198}
199#[derive(Debug, Clone, PartialEq, Eq, Hash)]
200pub struct RBrack {
201 pub(crate) syntax: SyntaxToken,
202}
203impl std::fmt::Display for RBrack {
204 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
205 std::fmt::Display::fmt(&self.syntax, f)
206 }
207}
208impl AstToken for RBrack {
209 fn can_cast(kind: SyntaxKind) -> bool {
210 match kind {
211 R_BRACK => true,
212 _ => false,
213 }
214 }
215 fn cast(syntax: SyntaxToken) -> Option<Self> {
216 if Self::can_cast(syntax.kind()) {
217 Some(Self { syntax })
218 } else {
219 None
220 }
221 }
222 fn syntax(&self) -> &SyntaxToken {
223 &self.syntax
224 }
225}
226#[derive(Debug, Clone, PartialEq, Eq, Hash)]
227pub struct LAngle {
228 pub(crate) syntax: SyntaxToken,
229}
230impl std::fmt::Display for LAngle {
231 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
232 std::fmt::Display::fmt(&self.syntax, f)
233 }
234}
235impl AstToken for LAngle {
236 fn can_cast(kind: SyntaxKind) -> bool {
237 match kind {
238 L_ANGLE => true,
239 _ => false,
240 }
241 }
242 fn cast(syntax: SyntaxToken) -> Option<Self> {
243 if Self::can_cast(syntax.kind()) {
244 Some(Self { syntax })
245 } else {
246 None
247 }
248 }
249 fn syntax(&self) -> &SyntaxToken {
250 &self.syntax
251 }
252}
253#[derive(Debug, Clone, PartialEq, Eq, Hash)]
254pub struct RAngle {
255 pub(crate) syntax: SyntaxToken,
256}
257impl std::fmt::Display for RAngle {
258 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
259 std::fmt::Display::fmt(&self.syntax, f)
260 }
261}
262impl AstToken for RAngle {
263 fn can_cast(kind: SyntaxKind) -> bool {
264 match kind {
265 R_ANGLE => true,
266 _ => false,
267 }
268 }
269 fn cast(syntax: SyntaxToken) -> Option<Self> {
270 if Self::can_cast(syntax.kind()) {
271 Some(Self { syntax })
272 } else {
273 None
274 }
275 }
276 fn syntax(&self) -> &SyntaxToken {
277 &self.syntax
278 }
279}
280#[derive(Debug, Clone, PartialEq, Eq, Hash)]
281pub struct At {
282 pub(crate) syntax: SyntaxToken,
283}
284impl std::fmt::Display for At {
285 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
286 std::fmt::Display::fmt(&self.syntax, f)
287 }
288}
289impl AstToken for At {
290 fn can_cast(kind: SyntaxKind) -> bool {
291 match kind {
292 AT => true,
293 _ => false,
294 }
295 }
296 fn cast(syntax: SyntaxToken) -> Option<Self> {
297 if Self::can_cast(syntax.kind()) {
298 Some(Self { syntax })
299 } else {
300 None
301 }
302 }
303 fn syntax(&self) -> &SyntaxToken {
304 &self.syntax
305 }
306}
307#[derive(Debug, Clone, PartialEq, Eq, Hash)]
308pub struct Pound {
309 pub(crate) syntax: SyntaxToken,
310}
311impl std::fmt::Display for Pound {
312 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
313 std::fmt::Display::fmt(&self.syntax, f)
314 }
315}
316impl AstToken for Pound {
317 fn can_cast(kind: SyntaxKind) -> bool {
318 match kind {
319 POUND => true,
320 _ => false,
321 }
322 }
323 fn cast(syntax: SyntaxToken) -> Option<Self> {
324 if Self::can_cast(syntax.kind()) {
325 Some(Self { syntax })
326 } else {
327 None
328 }
329 }
330 fn syntax(&self) -> &SyntaxToken {
331 &self.syntax
332 }
333}
334#[derive(Debug, Clone, PartialEq, Eq, Hash)]
335pub struct Tilde {
336 pub(crate) syntax: SyntaxToken,
337}
338impl std::fmt::Display for Tilde {
339 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
340 std::fmt::Display::fmt(&self.syntax, f)
341 }
342}
343impl AstToken for Tilde {
344 fn can_cast(kind: SyntaxKind) -> bool {
345 match kind {
346 TILDE => true,
347 _ => false,
348 }
349 }
350 fn cast(syntax: SyntaxToken) -> Option<Self> {
351 if Self::can_cast(syntax.kind()) {
352 Some(Self { syntax })
353 } else {
354 None
355 }
356 }
357 fn syntax(&self) -> &SyntaxToken {
358 &self.syntax
359 }
360}
361#[derive(Debug, Clone, PartialEq, Eq, Hash)]
362pub struct Question {
363 pub(crate) syntax: SyntaxToken,
364}
365impl std::fmt::Display for Question {
366 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
367 std::fmt::Display::fmt(&self.syntax, f)
368 }
369}
370impl AstToken for Question {
371 fn can_cast(kind: SyntaxKind) -> bool {
372 match kind {
373 QUESTION => true,
374 _ => false,
375 }
376 }
377 fn cast(syntax: SyntaxToken) -> Option<Self> {
378 if Self::can_cast(syntax.kind()) {
379 Some(Self { syntax })
380 } else {
381 None
382 }
383 }
384 fn syntax(&self) -> &SyntaxToken {
385 &self.syntax
386 }
387}
388#[derive(Debug, Clone, PartialEq, Eq, Hash)]
389pub struct Dollar {
390 pub(crate) syntax: SyntaxToken,
391}
392impl std::fmt::Display for Dollar {
393 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
394 std::fmt::Display::fmt(&self.syntax, f)
395 }
396}
397impl AstToken for Dollar {
398 fn can_cast(kind: SyntaxKind) -> bool {
399 match kind {
400 DOLLAR => true,
401 _ => false,
402 }
403 }
404 fn cast(syntax: SyntaxToken) -> Option<Self> {
405 if Self::can_cast(syntax.kind()) {
406 Some(Self { syntax })
407 } else {
408 None
409 }
410 }
411 fn syntax(&self) -> &SyntaxToken {
412 &self.syntax
413 }
414}
415#[derive(Debug, Clone, PartialEq, Eq, Hash)]
416pub struct Amp {
417 pub(crate) syntax: SyntaxToken,
418}
419impl std::fmt::Display for Amp {
420 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
421 std::fmt::Display::fmt(&self.syntax, f)
422 }
423}
424impl AstToken for Amp {
425 fn can_cast(kind: SyntaxKind) -> bool {
426 match kind {
427 AMP => true,
428 _ => false,
429 }
430 }
431 fn cast(syntax: SyntaxToken) -> Option<Self> {
432 if Self::can_cast(syntax.kind()) {
433 Some(Self { syntax })
434 } else {
435 None
436 }
437 }
438 fn syntax(&self) -> &SyntaxToken {
439 &self.syntax
440 }
441}
442#[derive(Debug, Clone, PartialEq, Eq, Hash)]
443pub struct Pipe {
444 pub(crate) syntax: SyntaxToken,
445}
446impl std::fmt::Display for Pipe {
447 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
448 std::fmt::Display::fmt(&self.syntax, f)
449 }
450}
451impl AstToken for Pipe {
452 fn can_cast(kind: SyntaxKind) -> bool {
453 match kind {
454 PIPE => true,
455 _ => false,
456 }
457 }
458 fn cast(syntax: SyntaxToken) -> Option<Self> {
459 if Self::can_cast(syntax.kind()) {
460 Some(Self { syntax })
461 } else {
462 None
463 }
464 }
465 fn syntax(&self) -> &SyntaxToken {
466 &self.syntax
467 }
468}
469#[derive(Debug, Clone, PartialEq, Eq, Hash)]
470pub struct Plus {
471 pub(crate) syntax: SyntaxToken,
472}
473impl std::fmt::Display for Plus {
474 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
475 std::fmt::Display::fmt(&self.syntax, f)
476 }
477}
478impl AstToken for Plus {
479 fn can_cast(kind: SyntaxKind) -> bool {
480 match kind {
481 PLUS => true,
482 _ => false,
483 }
484 }
485 fn cast(syntax: SyntaxToken) -> Option<Self> {
486 if Self::can_cast(syntax.kind()) {
487 Some(Self { syntax })
488 } else {
489 None
490 }
491 }
492 fn syntax(&self) -> &SyntaxToken {
493 &self.syntax
494 }
495}
496#[derive(Debug, Clone, PartialEq, Eq, Hash)]
497pub struct Star {
498 pub(crate) syntax: SyntaxToken,
499}
500impl std::fmt::Display for Star {
501 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
502 std::fmt::Display::fmt(&self.syntax, f)
503 }
504}
505impl AstToken for Star {
506 fn can_cast(kind: SyntaxKind) -> bool {
507 match kind {
508 STAR => true,
509 _ => false,
510 }
511 }
512 fn cast(syntax: SyntaxToken) -> Option<Self> {
513 if Self::can_cast(syntax.kind()) {
514 Some(Self { syntax })
515 } else {
516 None
517 }
518 }
519 fn syntax(&self) -> &SyntaxToken {
520 &self.syntax
521 }
522}
523#[derive(Debug, Clone, PartialEq, Eq, Hash)]
524pub struct Slash {
525 pub(crate) syntax: SyntaxToken,
526}
527impl std::fmt::Display for Slash {
528 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
529 std::fmt::Display::fmt(&self.syntax, f)
530 }
531}
532impl AstToken for Slash {
533 fn can_cast(kind: SyntaxKind) -> bool {
534 match kind {
535 SLASH => true,
536 _ => false,
537 }
538 }
539 fn cast(syntax: SyntaxToken) -> Option<Self> {
540 if Self::can_cast(syntax.kind()) {
541 Some(Self { syntax })
542 } else {
543 None
544 }
545 }
546 fn syntax(&self) -> &SyntaxToken {
547 &self.syntax
548 }
549}
550#[derive(Debug, Clone, PartialEq, Eq, Hash)]
551pub struct Caret {
552 pub(crate) syntax: SyntaxToken,
553}
554impl std::fmt::Display for Caret {
555 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
556 std::fmt::Display::fmt(&self.syntax, f)
557 }
558}
559impl AstToken for Caret {
560 fn can_cast(kind: SyntaxKind) -> bool {
561 match kind {
562 CARET => true,
563 _ => false,
564 }
565 }
566 fn cast(syntax: SyntaxToken) -> Option<Self> {
567 if Self::can_cast(syntax.kind()) {
568 Some(Self { syntax })
569 } else {
570 None
571 }
572 }
573 fn syntax(&self) -> &SyntaxToken {
574 &self.syntax
575 }
576}
577#[derive(Debug, Clone, PartialEq, Eq, Hash)]
578pub struct Percent {
579 pub(crate) syntax: SyntaxToken,
580}
581impl std::fmt::Display for Percent {
582 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
583 std::fmt::Display::fmt(&self.syntax, f)
584 }
585}
586impl AstToken for Percent {
587 fn can_cast(kind: SyntaxKind) -> bool {
588 match kind {
589 PERCENT => true,
590 _ => false,
591 }
592 }
593 fn cast(syntax: SyntaxToken) -> Option<Self> {
594 if Self::can_cast(syntax.kind()) {
595 Some(Self { syntax })
596 } else {
597 None
598 }
599 }
600 fn syntax(&self) -> &SyntaxToken {
601 &self.syntax
602 }
603}
604#[derive(Debug, Clone, PartialEq, Eq, Hash)]
605pub struct Underscore {
606 pub(crate) syntax: SyntaxToken,
607}
608impl std::fmt::Display for Underscore {
609 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
610 std::fmt::Display::fmt(&self.syntax, f)
611 }
612}
613impl AstToken for Underscore {
614 fn can_cast(kind: SyntaxKind) -> bool {
615 match kind {
616 UNDERSCORE => true,
617 _ => false,
618 }
619 }
620 fn cast(syntax: SyntaxToken) -> Option<Self> {
621 if Self::can_cast(syntax.kind()) {
622 Some(Self { syntax })
623 } else {
624 None
625 }
626 }
627 fn syntax(&self) -> &SyntaxToken {
628 &self.syntax
629 }
630}
631#[derive(Debug, Clone, PartialEq, Eq, Hash)]
632pub struct Dot {
633 pub(crate) syntax: SyntaxToken,
634}
635impl std::fmt::Display for Dot {
636 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
637 std::fmt::Display::fmt(&self.syntax, f)
638 }
639}
640impl AstToken for Dot {
641 fn can_cast(kind: SyntaxKind) -> bool {
642 match kind {
643 DOT => true,
644 _ => false,
645 }
646 }
647 fn cast(syntax: SyntaxToken) -> Option<Self> {
648 if Self::can_cast(syntax.kind()) {
649 Some(Self { syntax })
650 } else {
651 None
652 }
653 }
654 fn syntax(&self) -> &SyntaxToken {
655 &self.syntax
656 }
657}
658#[derive(Debug, Clone, PartialEq, Eq, Hash)]
659pub struct Dotdot {
660 pub(crate) syntax: SyntaxToken,
661}
662impl std::fmt::Display for Dotdot {
663 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
664 std::fmt::Display::fmt(&self.syntax, f)
665 }
666}
667impl AstToken for Dotdot {
668 fn can_cast(kind: SyntaxKind) -> bool {
669 match kind {
670 DOTDOT => true,
671 _ => false,
672 }
673 }
674 fn cast(syntax: SyntaxToken) -> Option<Self> {
675 if Self::can_cast(syntax.kind()) {
676 Some(Self { syntax })
677 } else {
678 None
679 }
680 }
681 fn syntax(&self) -> &SyntaxToken {
682 &self.syntax
683 }
684}
685#[derive(Debug, Clone, PartialEq, Eq, Hash)]
686pub struct Dotdotdot {
687 pub(crate) syntax: SyntaxToken,
688}
689impl std::fmt::Display for Dotdotdot {
690 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
691 std::fmt::Display::fmt(&self.syntax, f)
692 }
693}
694impl AstToken for Dotdotdot {
695 fn can_cast(kind: SyntaxKind) -> bool {
696 match kind {
697 DOTDOTDOT => true,
698 _ => false,
699 }
700 }
701 fn cast(syntax: SyntaxToken) -> Option<Self> {
702 if Self::can_cast(syntax.kind()) {
703 Some(Self { syntax })
704 } else {
705 None
706 }
707 }
708 fn syntax(&self) -> &SyntaxToken {
709 &self.syntax
710 }
711}
712#[derive(Debug, Clone, PartialEq, Eq, Hash)]
713pub struct Dotdoteq {
714 pub(crate) syntax: SyntaxToken,
715}
716impl std::fmt::Display for Dotdoteq {
717 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
718 std::fmt::Display::fmt(&self.syntax, f)
719 }
720}
721impl AstToken for Dotdoteq {
722 fn can_cast(kind: SyntaxKind) -> bool {
723 match kind {
724 DOTDOTEQ => true,
725 _ => false,
726 }
727 }
728 fn cast(syntax: SyntaxToken) -> Option<Self> {
729 if Self::can_cast(syntax.kind()) {
730 Some(Self { syntax })
731 } else {
732 None
733 }
734 }
735 fn syntax(&self) -> &SyntaxToken {
736 &self.syntax
737 }
738}
739#[derive(Debug, Clone, PartialEq, Eq, Hash)]
740pub struct Colon {
741 pub(crate) syntax: SyntaxToken,
742}
743impl std::fmt::Display for Colon {
744 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
745 std::fmt::Display::fmt(&self.syntax, f)
746 }
747}
748impl AstToken for Colon {
749 fn can_cast(kind: SyntaxKind) -> bool {
750 match kind {
751 COLON => true,
752 _ => false,
753 }
754 }
755 fn cast(syntax: SyntaxToken) -> Option<Self> {
756 if Self::can_cast(syntax.kind()) {
757 Some(Self { syntax })
758 } else {
759 None
760 }
761 }
762 fn syntax(&self) -> &SyntaxToken {
763 &self.syntax
764 }
765}
766#[derive(Debug, Clone, PartialEq, Eq, Hash)]
767pub struct Coloncolon {
768 pub(crate) syntax: SyntaxToken,
769}
770impl std::fmt::Display for Coloncolon {
771 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
772 std::fmt::Display::fmt(&self.syntax, f)
773 }
774}
775impl AstToken for Coloncolon {
776 fn can_cast(kind: SyntaxKind) -> bool {
777 match kind {
778 COLONCOLON => true,
779 _ => false,
780 }
781 }
782 fn cast(syntax: SyntaxToken) -> Option<Self> {
783 if Self::can_cast(syntax.kind()) {
784 Some(Self { syntax })
785 } else {
786 None
787 }
788 }
789 fn syntax(&self) -> &SyntaxToken {
790 &self.syntax
791 }
792}
793#[derive(Debug, Clone, PartialEq, Eq, Hash)]
794pub struct Eq {
795 pub(crate) syntax: SyntaxToken,
796}
797impl std::fmt::Display for Eq {
798 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
799 std::fmt::Display::fmt(&self.syntax, f)
800 }
801}
802impl AstToken for Eq {
803 fn can_cast(kind: SyntaxKind) -> bool {
804 match kind {
805 EQ => true,
806 _ => false,
807 }
808 }
809 fn cast(syntax: SyntaxToken) -> Option<Self> {
810 if Self::can_cast(syntax.kind()) {
811 Some(Self { syntax })
812 } else {
813 None
814 }
815 }
816 fn syntax(&self) -> &SyntaxToken {
817 &self.syntax
818 }
819}
820#[derive(Debug, Clone, PartialEq, Eq, Hash)]
821pub struct Eqeq {
822 pub(crate) syntax: SyntaxToken,
823}
824impl std::fmt::Display for Eqeq {
825 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
826 std::fmt::Display::fmt(&self.syntax, f)
827 }
828}
829impl AstToken for Eqeq {
830 fn can_cast(kind: SyntaxKind) -> bool {
831 match kind {
832 EQEQ => true,
833 _ => false,
834 }
835 }
836 fn cast(syntax: SyntaxToken) -> Option<Self> {
837 if Self::can_cast(syntax.kind()) {
838 Some(Self { syntax })
839 } else {
840 None
841 }
842 }
843 fn syntax(&self) -> &SyntaxToken {
844 &self.syntax
845 }
846}
847#[derive(Debug, Clone, PartialEq, Eq, Hash)]
848pub struct FatArrow {
849 pub(crate) syntax: SyntaxToken,
850}
851impl std::fmt::Display for FatArrow {
852 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
853 std::fmt::Display::fmt(&self.syntax, f)
854 }
855}
856impl AstToken for FatArrow {
857 fn can_cast(kind: SyntaxKind) -> bool {
858 match kind {
859 FAT_ARROW => true,
860 _ => false,
861 }
862 }
863 fn cast(syntax: SyntaxToken) -> Option<Self> {
864 if Self::can_cast(syntax.kind()) {
865 Some(Self { syntax })
866 } else {
867 None
868 }
869 }
870 fn syntax(&self) -> &SyntaxToken {
871 &self.syntax
872 }
873}
874#[derive(Debug, Clone, PartialEq, Eq, Hash)]
875pub struct Excl {
876 pub(crate) syntax: SyntaxToken,
877}
878impl std::fmt::Display for Excl {
879 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
880 std::fmt::Display::fmt(&self.syntax, f)
881 }
882}
883impl AstToken for Excl {
884 fn can_cast(kind: SyntaxKind) -> bool {
885 match kind {
886 EXCL => true,
887 _ => false,
888 }
889 }
890 fn cast(syntax: SyntaxToken) -> Option<Self> {
891 if Self::can_cast(syntax.kind()) {
892 Some(Self { syntax })
893 } else {
894 None
895 }
896 }
897 fn syntax(&self) -> &SyntaxToken {
898 &self.syntax
899 }
900}
901#[derive(Debug, Clone, PartialEq, Eq, Hash)]
902pub struct Neq {
903 pub(crate) syntax: SyntaxToken,
904}
905impl std::fmt::Display for Neq {
906 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
907 std::fmt::Display::fmt(&self.syntax, f)
908 }
909}
910impl AstToken for Neq {
911 fn can_cast(kind: SyntaxKind) -> bool {
912 match kind {
913 NEQ => true,
914 _ => false,
915 }
916 }
917 fn cast(syntax: SyntaxToken) -> Option<Self> {
918 if Self::can_cast(syntax.kind()) {
919 Some(Self { syntax })
920 } else {
921 None
922 }
923 }
924 fn syntax(&self) -> &SyntaxToken {
925 &self.syntax
926 }
927}
928#[derive(Debug, Clone, PartialEq, Eq, Hash)]
929pub struct Minus {
930 pub(crate) syntax: SyntaxToken,
931}
932impl std::fmt::Display for Minus {
933 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
934 std::fmt::Display::fmt(&self.syntax, f)
935 }
936}
937impl AstToken for Minus {
938 fn can_cast(kind: SyntaxKind) -> bool {
939 match kind {
940 MINUS => true,
941 _ => false,
942 }
943 }
944 fn cast(syntax: SyntaxToken) -> Option<Self> {
945 if Self::can_cast(syntax.kind()) {
946 Some(Self { syntax })
947 } else {
948 None
949 }
950 }
951 fn syntax(&self) -> &SyntaxToken {
952 &self.syntax
953 }
954}
955#[derive(Debug, Clone, PartialEq, Eq, Hash)]
956pub struct ThinArrow {
957 pub(crate) syntax: SyntaxToken,
958}
959impl std::fmt::Display for ThinArrow {
960 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
961 std::fmt::Display::fmt(&self.syntax, f)
962 }
963}
964impl AstToken for ThinArrow {
965 fn can_cast(kind: SyntaxKind) -> bool {
966 match kind {
967 THIN_ARROW => true,
968 _ => false,
969 }
970 }
971 fn cast(syntax: SyntaxToken) -> Option<Self> {
972 if Self::can_cast(syntax.kind()) {
973 Some(Self { syntax })
974 } else {
975 None
976 }
977 }
978 fn syntax(&self) -> &SyntaxToken {
979 &self.syntax
980 }
981}
982#[derive(Debug, Clone, PartialEq, Eq, Hash)]
983pub struct Lteq {
984 pub(crate) syntax: SyntaxToken,
985}
986impl std::fmt::Display for Lteq {
987 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
988 std::fmt::Display::fmt(&self.syntax, f)
989 }
990}
991impl AstToken for Lteq {
992 fn can_cast(kind: SyntaxKind) -> bool {
993 match kind {
994 LTEQ => true,
995 _ => false,
996 }
997 }
998 fn cast(syntax: SyntaxToken) -> Option<Self> {
999 if Self::can_cast(syntax.kind()) {
1000 Some(Self { syntax })
1001 } else {
1002 None
1003 }
1004 }
1005 fn syntax(&self) -> &SyntaxToken {
1006 &self.syntax
1007 }
1008}
1009#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1010pub struct Gteq {
1011 pub(crate) syntax: SyntaxToken,
1012}
1013impl std::fmt::Display for Gteq {
1014 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1015 std::fmt::Display::fmt(&self.syntax, f)
1016 }
1017}
1018impl AstToken for Gteq {
1019 fn can_cast(kind: SyntaxKind) -> bool {
1020 match kind {
1021 GTEQ => true,
1022 _ => false,
1023 }
1024 }
1025 fn cast(syntax: SyntaxToken) -> Option<Self> {
1026 if Self::can_cast(syntax.kind()) {
1027 Some(Self { syntax })
1028 } else {
1029 None
1030 }
1031 }
1032 fn syntax(&self) -> &SyntaxToken {
1033 &self.syntax
1034 }
1035}
1036#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1037pub struct Pluseq {
1038 pub(crate) syntax: SyntaxToken,
1039}
1040impl std::fmt::Display for Pluseq {
1041 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1042 std::fmt::Display::fmt(&self.syntax, f)
1043 }
1044}
1045impl AstToken for Pluseq {
1046 fn can_cast(kind: SyntaxKind) -> bool {
1047 match kind {
1048 PLUSEQ => true,
1049 _ => false,
1050 }
1051 }
1052 fn cast(syntax: SyntaxToken) -> Option<Self> {
1053 if Self::can_cast(syntax.kind()) {
1054 Some(Self { syntax })
1055 } else {
1056 None
1057 }
1058 }
1059 fn syntax(&self) -> &SyntaxToken {
1060 &self.syntax
1061 }
1062}
1063#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1064pub struct Minuseq {
1065 pub(crate) syntax: SyntaxToken,
1066}
1067impl std::fmt::Display for Minuseq {
1068 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1069 std::fmt::Display::fmt(&self.syntax, f)
1070 }
1071}
1072impl AstToken for Minuseq {
1073 fn can_cast(kind: SyntaxKind) -> bool {
1074 match kind {
1075 MINUSEQ => true,
1076 _ => false,
1077 }
1078 }
1079 fn cast(syntax: SyntaxToken) -> Option<Self> {
1080 if Self::can_cast(syntax.kind()) {
1081 Some(Self { syntax })
1082 } else {
1083 None
1084 }
1085 }
1086 fn syntax(&self) -> &SyntaxToken {
1087 &self.syntax
1088 }
1089}
1090#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1091pub struct Pipeeq {
1092 pub(crate) syntax: SyntaxToken,
1093}
1094impl std::fmt::Display for Pipeeq {
1095 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1096 std::fmt::Display::fmt(&self.syntax, f)
1097 }
1098}
1099impl AstToken for Pipeeq {
1100 fn can_cast(kind: SyntaxKind) -> bool {
1101 match kind {
1102 PIPEEQ => true,
1103 _ => false,
1104 }
1105 }
1106 fn cast(syntax: SyntaxToken) -> Option<Self> {
1107 if Self::can_cast(syntax.kind()) {
1108 Some(Self { syntax })
1109 } else {
1110 None
1111 }
1112 }
1113 fn syntax(&self) -> &SyntaxToken {
1114 &self.syntax
1115 }
1116}
1117#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1118pub struct Ampeq {
1119 pub(crate) syntax: SyntaxToken,
1120}
1121impl std::fmt::Display for Ampeq {
1122 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1123 std::fmt::Display::fmt(&self.syntax, f)
1124 }
1125}
1126impl AstToken for Ampeq {
1127 fn can_cast(kind: SyntaxKind) -> bool {
1128 match kind {
1129 AMPEQ => true,
1130 _ => false,
1131 }
1132 }
1133 fn cast(syntax: SyntaxToken) -> Option<Self> {
1134 if Self::can_cast(syntax.kind()) {
1135 Some(Self { syntax })
1136 } else {
1137 None
1138 }
1139 }
1140 fn syntax(&self) -> &SyntaxToken {
1141 &self.syntax
1142 }
1143}
1144#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1145pub struct Careteq {
1146 pub(crate) syntax: SyntaxToken,
1147}
1148impl std::fmt::Display for Careteq {
1149 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1150 std::fmt::Display::fmt(&self.syntax, f)
1151 }
1152}
1153impl AstToken for Careteq {
1154 fn can_cast(kind: SyntaxKind) -> bool {
1155 match kind {
1156 CARETEQ => true,
1157 _ => false,
1158 }
1159 }
1160 fn cast(syntax: SyntaxToken) -> Option<Self> {
1161 if Self::can_cast(syntax.kind()) {
1162 Some(Self { syntax })
1163 } else {
1164 None
1165 }
1166 }
1167 fn syntax(&self) -> &SyntaxToken {
1168 &self.syntax
1169 }
1170}
1171#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1172pub struct Slasheq {
1173 pub(crate) syntax: SyntaxToken,
1174}
1175impl std::fmt::Display for Slasheq {
1176 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1177 std::fmt::Display::fmt(&self.syntax, f)
1178 }
1179}
1180impl AstToken for Slasheq {
1181 fn can_cast(kind: SyntaxKind) -> bool {
1182 match kind {
1183 SLASHEQ => true,
1184 _ => false,
1185 }
1186 }
1187 fn cast(syntax: SyntaxToken) -> Option<Self> {
1188 if Self::can_cast(syntax.kind()) {
1189 Some(Self { syntax })
1190 } else {
1191 None
1192 }
1193 }
1194 fn syntax(&self) -> &SyntaxToken {
1195 &self.syntax
1196 }
1197}
1198#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1199pub struct Stareq {
1200 pub(crate) syntax: SyntaxToken,
1201}
1202impl std::fmt::Display for Stareq {
1203 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1204 std::fmt::Display::fmt(&self.syntax, f)
1205 }
1206}
1207impl AstToken for Stareq {
1208 fn can_cast(kind: SyntaxKind) -> bool {
1209 match kind {
1210 STAREQ => true,
1211 _ => false,
1212 }
1213 }
1214 fn cast(syntax: SyntaxToken) -> Option<Self> {
1215 if Self::can_cast(syntax.kind()) {
1216 Some(Self { syntax })
1217 } else {
1218 None
1219 }
1220 }
1221 fn syntax(&self) -> &SyntaxToken {
1222 &self.syntax
1223 }
1224}
1225#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1226pub struct Percenteq {
1227 pub(crate) syntax: SyntaxToken,
1228}
1229impl std::fmt::Display for Percenteq {
1230 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1231 std::fmt::Display::fmt(&self.syntax, f)
1232 }
1233}
1234impl AstToken for Percenteq {
1235 fn can_cast(kind: SyntaxKind) -> bool {
1236 match kind {
1237 PERCENTEQ => true,
1238 _ => false,
1239 }
1240 }
1241 fn cast(syntax: SyntaxToken) -> Option<Self> {
1242 if Self::can_cast(syntax.kind()) {
1243 Some(Self { syntax })
1244 } else {
1245 None
1246 }
1247 }
1248 fn syntax(&self) -> &SyntaxToken {
1249 &self.syntax
1250 }
1251}
1252#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1253pub struct Ampamp {
1254 pub(crate) syntax: SyntaxToken,
1255}
1256impl std::fmt::Display for Ampamp {
1257 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1258 std::fmt::Display::fmt(&self.syntax, f)
1259 }
1260}
1261impl AstToken for Ampamp {
1262 fn can_cast(kind: SyntaxKind) -> bool {
1263 match kind {
1264 AMPAMP => true,
1265 _ => false,
1266 }
1267 }
1268 fn cast(syntax: SyntaxToken) -> Option<Self> {
1269 if Self::can_cast(syntax.kind()) {
1270 Some(Self { syntax })
1271 } else {
1272 None
1273 }
1274 }
1275 fn syntax(&self) -> &SyntaxToken {
1276 &self.syntax
1277 }
1278}
1279#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1280pub struct Pipepipe {
1281 pub(crate) syntax: SyntaxToken,
1282}
1283impl std::fmt::Display for Pipepipe {
1284 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1285 std::fmt::Display::fmt(&self.syntax, f)
1286 }
1287}
1288impl AstToken for Pipepipe {
1289 fn can_cast(kind: SyntaxKind) -> bool {
1290 match kind {
1291 PIPEPIPE => true,
1292 _ => false,
1293 }
1294 }
1295 fn cast(syntax: SyntaxToken) -> Option<Self> {
1296 if Self::can_cast(syntax.kind()) {
1297 Some(Self { syntax })
1298 } else {
1299 None
1300 }
1301 }
1302 fn syntax(&self) -> &SyntaxToken {
1303 &self.syntax
1304 }
1305}
1306#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1307pub struct Shl {
1308 pub(crate) syntax: SyntaxToken,
1309}
1310impl std::fmt::Display for Shl {
1311 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1312 std::fmt::Display::fmt(&self.syntax, f)
1313 }
1314}
1315impl AstToken for Shl {
1316 fn can_cast(kind: SyntaxKind) -> bool {
1317 match kind {
1318 SHL => true,
1319 _ => false,
1320 }
1321 }
1322 fn cast(syntax: SyntaxToken) -> Option<Self> {
1323 if Self::can_cast(syntax.kind()) {
1324 Some(Self { syntax })
1325 } else {
1326 None
1327 }
1328 }
1329 fn syntax(&self) -> &SyntaxToken {
1330 &self.syntax
1331 }
1332}
1333#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1334pub struct Shr {
1335 pub(crate) syntax: SyntaxToken,
1336}
1337impl std::fmt::Display for Shr {
1338 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1339 std::fmt::Display::fmt(&self.syntax, f)
1340 }
1341}
1342impl AstToken for Shr {
1343 fn can_cast(kind: SyntaxKind) -> bool {
1344 match kind {
1345 SHR => true,
1346 _ => false,
1347 }
1348 }
1349 fn cast(syntax: SyntaxToken) -> Option<Self> {
1350 if Self::can_cast(syntax.kind()) {
1351 Some(Self { syntax })
1352 } else {
1353 None
1354 }
1355 }
1356 fn syntax(&self) -> &SyntaxToken {
1357 &self.syntax
1358 }
1359}
1360#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1361pub struct Shleq {
1362 pub(crate) syntax: SyntaxToken,
1363}
1364impl std::fmt::Display for Shleq {
1365 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1366 std::fmt::Display::fmt(&self.syntax, f)
1367 }
1368}
1369impl AstToken for Shleq {
1370 fn can_cast(kind: SyntaxKind) -> bool {
1371 match kind {
1372 SHLEQ => true,
1373 _ => false,
1374 }
1375 }
1376 fn cast(syntax: SyntaxToken) -> Option<Self> {
1377 if Self::can_cast(syntax.kind()) {
1378 Some(Self { syntax })
1379 } else {
1380 None
1381 }
1382 }
1383 fn syntax(&self) -> &SyntaxToken {
1384 &self.syntax
1385 }
1386}
1387#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1388pub struct Shreq {
1389 pub(crate) syntax: SyntaxToken,
1390}
1391impl std::fmt::Display for Shreq {
1392 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1393 std::fmt::Display::fmt(&self.syntax, f)
1394 }
1395}
1396impl AstToken for Shreq {
1397 fn can_cast(kind: SyntaxKind) -> bool {
1398 match kind {
1399 SHREQ => true,
1400 _ => false,
1401 }
1402 }
1403 fn cast(syntax: SyntaxToken) -> Option<Self> {
1404 if Self::can_cast(syntax.kind()) {
1405 Some(Self { syntax })
1406 } else {
1407 None
1408 }
1409 }
1410 fn syntax(&self) -> &SyntaxToken {
1411 &self.syntax
1412 }
1413}
1414#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1415pub struct AsKw {
1416 pub(crate) syntax: SyntaxToken,
1417}
1418impl std::fmt::Display for AsKw {
1419 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1420 std::fmt::Display::fmt(&self.syntax, f)
1421 }
1422}
1423impl AstToken for AsKw {
1424 fn can_cast(kind: SyntaxKind) -> bool {
1425 match kind {
1426 AS_KW => true,
1427 _ => false,
1428 }
1429 }
1430 fn cast(syntax: SyntaxToken) -> Option<Self> {
1431 if Self::can_cast(syntax.kind()) {
1432 Some(Self { syntax })
1433 } else {
1434 None
1435 }
1436 }
1437 fn syntax(&self) -> &SyntaxToken {
1438 &self.syntax
1439 }
1440}
1441#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1442pub struct AsyncKw {
1443 pub(crate) syntax: SyntaxToken,
1444}
1445impl std::fmt::Display for AsyncKw {
1446 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1447 std::fmt::Display::fmt(&self.syntax, f)
1448 }
1449}
1450impl AstToken for AsyncKw {
1451 fn can_cast(kind: SyntaxKind) -> bool {
1452 match kind {
1453 ASYNC_KW => true,
1454 _ => false,
1455 }
1456 }
1457 fn cast(syntax: SyntaxToken) -> Option<Self> {
1458 if Self::can_cast(syntax.kind()) {
1459 Some(Self { syntax })
1460 } else {
1461 None
1462 }
1463 }
1464 fn syntax(&self) -> &SyntaxToken {
1465 &self.syntax
1466 }
1467}
1468#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1469pub struct AwaitKw {
1470 pub(crate) syntax: SyntaxToken,
1471}
1472impl std::fmt::Display for AwaitKw {
1473 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1474 std::fmt::Display::fmt(&self.syntax, f)
1475 }
1476}
1477impl AstToken for AwaitKw {
1478 fn can_cast(kind: SyntaxKind) -> bool {
1479 match kind {
1480 AWAIT_KW => true,
1481 _ => false,
1482 }
1483 }
1484 fn cast(syntax: SyntaxToken) -> Option<Self> {
1485 if Self::can_cast(syntax.kind()) {
1486 Some(Self { syntax })
1487 } else {
1488 None
1489 }
1490 }
1491 fn syntax(&self) -> &SyntaxToken {
1492 &self.syntax
1493 }
1494}
1495#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1496pub struct BoxKw {
1497 pub(crate) syntax: SyntaxToken,
1498}
1499impl std::fmt::Display for BoxKw {
1500 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1501 std::fmt::Display::fmt(&self.syntax, f)
1502 }
1503}
1504impl AstToken for BoxKw {
1505 fn can_cast(kind: SyntaxKind) -> bool {
1506 match kind {
1507 BOX_KW => true,
1508 _ => false,
1509 }
1510 }
1511 fn cast(syntax: SyntaxToken) -> Option<Self> {
1512 if Self::can_cast(syntax.kind()) {
1513 Some(Self { syntax })
1514 } else {
1515 None
1516 }
1517 }
1518 fn syntax(&self) -> &SyntaxToken {
1519 &self.syntax
1520 }
1521}
1522#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1523pub struct BreakKw {
1524 pub(crate) syntax: SyntaxToken,
1525}
1526impl std::fmt::Display for BreakKw {
1527 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1528 std::fmt::Display::fmt(&self.syntax, f)
1529 }
1530}
1531impl AstToken for BreakKw {
1532 fn can_cast(kind: SyntaxKind) -> bool {
1533 match kind {
1534 BREAK_KW => true,
1535 _ => false,
1536 }
1537 }
1538 fn cast(syntax: SyntaxToken) -> Option<Self> {
1539 if Self::can_cast(syntax.kind()) {
1540 Some(Self { syntax })
1541 } else {
1542 None
1543 }
1544 }
1545 fn syntax(&self) -> &SyntaxToken {
1546 &self.syntax
1547 }
1548}
1549#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1550pub struct ConstKw {
1551 pub(crate) syntax: SyntaxToken,
1552}
1553impl std::fmt::Display for ConstKw {
1554 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1555 std::fmt::Display::fmt(&self.syntax, f)
1556 }
1557}
1558impl AstToken for ConstKw {
1559 fn can_cast(kind: SyntaxKind) -> bool {
1560 match kind {
1561 CONST_KW => true,
1562 _ => false,
1563 }
1564 }
1565 fn cast(syntax: SyntaxToken) -> Option<Self> {
1566 if Self::can_cast(syntax.kind()) {
1567 Some(Self { syntax })
1568 } else {
1569 None
1570 }
1571 }
1572 fn syntax(&self) -> &SyntaxToken {
1573 &self.syntax
1574 }
1575}
1576#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1577pub struct ContinueKw {
1578 pub(crate) syntax: SyntaxToken,
1579}
1580impl std::fmt::Display for ContinueKw {
1581 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1582 std::fmt::Display::fmt(&self.syntax, f)
1583 }
1584}
1585impl AstToken for ContinueKw {
1586 fn can_cast(kind: SyntaxKind) -> bool {
1587 match kind {
1588 CONTINUE_KW => true,
1589 _ => false,
1590 }
1591 }
1592 fn cast(syntax: SyntaxToken) -> Option<Self> {
1593 if Self::can_cast(syntax.kind()) {
1594 Some(Self { syntax })
1595 } else {
1596 None
1597 }
1598 }
1599 fn syntax(&self) -> &SyntaxToken {
1600 &self.syntax
1601 }
1602}
1603#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1604pub struct CrateKw {
1605 pub(crate) syntax: SyntaxToken,
1606}
1607impl std::fmt::Display for CrateKw {
1608 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1609 std::fmt::Display::fmt(&self.syntax, f)
1610 }
1611}
1612impl AstToken for CrateKw {
1613 fn can_cast(kind: SyntaxKind) -> bool {
1614 match kind {
1615 CRATE_KW => true,
1616 _ => false,
1617 }
1618 }
1619 fn cast(syntax: SyntaxToken) -> Option<Self> {
1620 if Self::can_cast(syntax.kind()) {
1621 Some(Self { syntax })
1622 } else {
1623 None
1624 }
1625 }
1626 fn syntax(&self) -> &SyntaxToken {
1627 &self.syntax
1628 }
1629}
1630#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1631pub struct DynKw {
1632 pub(crate) syntax: SyntaxToken,
1633}
1634impl std::fmt::Display for DynKw {
1635 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1636 std::fmt::Display::fmt(&self.syntax, f)
1637 }
1638}
1639impl AstToken for DynKw {
1640 fn can_cast(kind: SyntaxKind) -> bool {
1641 match kind {
1642 DYN_KW => true,
1643 _ => false,
1644 }
1645 }
1646 fn cast(syntax: SyntaxToken) -> Option<Self> {
1647 if Self::can_cast(syntax.kind()) {
1648 Some(Self { syntax })
1649 } else {
1650 None
1651 }
1652 }
1653 fn syntax(&self) -> &SyntaxToken {
1654 &self.syntax
1655 }
1656}
1657#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1658pub struct ElseKw {
1659 pub(crate) syntax: SyntaxToken,
1660}
1661impl std::fmt::Display for ElseKw {
1662 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1663 std::fmt::Display::fmt(&self.syntax, f)
1664 }
1665}
1666impl AstToken for ElseKw {
1667 fn can_cast(kind: SyntaxKind) -> bool {
1668 match kind {
1669 ELSE_KW => true,
1670 _ => false,
1671 }
1672 }
1673 fn cast(syntax: SyntaxToken) -> Option<Self> {
1674 if Self::can_cast(syntax.kind()) {
1675 Some(Self { syntax })
1676 } else {
1677 None
1678 }
1679 }
1680 fn syntax(&self) -> &SyntaxToken {
1681 &self.syntax
1682 }
1683}
1684#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1685pub struct EnumKw {
1686 pub(crate) syntax: SyntaxToken,
1687}
1688impl std::fmt::Display for EnumKw {
1689 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1690 std::fmt::Display::fmt(&self.syntax, f)
1691 }
1692}
1693impl AstToken for EnumKw {
1694 fn can_cast(kind: SyntaxKind) -> bool {
1695 match kind {
1696 ENUM_KW => true,
1697 _ => false,
1698 }
1699 }
1700 fn cast(syntax: SyntaxToken) -> Option<Self> {
1701 if Self::can_cast(syntax.kind()) {
1702 Some(Self { syntax })
1703 } else {
1704 None
1705 }
1706 }
1707 fn syntax(&self) -> &SyntaxToken {
1708 &self.syntax
1709 }
1710}
1711#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1712pub struct ExternKw {
1713 pub(crate) syntax: SyntaxToken,
1714}
1715impl std::fmt::Display for ExternKw {
1716 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1717 std::fmt::Display::fmt(&self.syntax, f)
1718 }
1719}
1720impl AstToken for ExternKw {
1721 fn can_cast(kind: SyntaxKind) -> bool {
1722 match kind {
1723 EXTERN_KW => true,
1724 _ => false,
1725 }
1726 }
1727 fn cast(syntax: SyntaxToken) -> Option<Self> {
1728 if Self::can_cast(syntax.kind()) {
1729 Some(Self { syntax })
1730 } else {
1731 None
1732 }
1733 }
1734 fn syntax(&self) -> &SyntaxToken {
1735 &self.syntax
1736 }
1737}
1738#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1739pub struct FalseKw {
1740 pub(crate) syntax: SyntaxToken,
1741}
1742impl std::fmt::Display for FalseKw {
1743 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1744 std::fmt::Display::fmt(&self.syntax, f)
1745 }
1746}
1747impl AstToken for FalseKw {
1748 fn can_cast(kind: SyntaxKind) -> bool {
1749 match kind {
1750 FALSE_KW => true,
1751 _ => false,
1752 }
1753 }
1754 fn cast(syntax: SyntaxToken) -> Option<Self> {
1755 if Self::can_cast(syntax.kind()) {
1756 Some(Self { syntax })
1757 } else {
1758 None
1759 }
1760 }
1761 fn syntax(&self) -> &SyntaxToken {
1762 &self.syntax
1763 }
1764}
1765#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1766pub struct FnKw {
1767 pub(crate) syntax: SyntaxToken,
1768}
1769impl std::fmt::Display for FnKw {
1770 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1771 std::fmt::Display::fmt(&self.syntax, f)
1772 }
1773}
1774impl AstToken for FnKw {
1775 fn can_cast(kind: SyntaxKind) -> bool {
1776 match kind {
1777 FN_KW => true,
1778 _ => false,
1779 }
1780 }
1781 fn cast(syntax: SyntaxToken) -> Option<Self> {
1782 if Self::can_cast(syntax.kind()) {
1783 Some(Self { syntax })
1784 } else {
1785 None
1786 }
1787 }
1788 fn syntax(&self) -> &SyntaxToken {
1789 &self.syntax
1790 }
1791}
1792#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1793pub struct ForKw {
1794 pub(crate) syntax: SyntaxToken,
1795}
1796impl std::fmt::Display for ForKw {
1797 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1798 std::fmt::Display::fmt(&self.syntax, f)
1799 }
1800}
1801impl AstToken for ForKw {
1802 fn can_cast(kind: SyntaxKind) -> bool {
1803 match kind {
1804 FOR_KW => true,
1805 _ => false,
1806 }
1807 }
1808 fn cast(syntax: SyntaxToken) -> Option<Self> {
1809 if Self::can_cast(syntax.kind()) {
1810 Some(Self { syntax })
1811 } else {
1812 None
1813 }
1814 }
1815 fn syntax(&self) -> &SyntaxToken {
1816 &self.syntax
1817 }
1818}
1819#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1820pub struct IfKw {
1821 pub(crate) syntax: SyntaxToken,
1822}
1823impl std::fmt::Display for IfKw {
1824 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1825 std::fmt::Display::fmt(&self.syntax, f)
1826 }
1827}
1828impl AstToken for IfKw {
1829 fn can_cast(kind: SyntaxKind) -> bool {
1830 match kind {
1831 IF_KW => true,
1832 _ => false,
1833 }
1834 }
1835 fn cast(syntax: SyntaxToken) -> Option<Self> {
1836 if Self::can_cast(syntax.kind()) {
1837 Some(Self { syntax })
1838 } else {
1839 None
1840 }
1841 }
1842 fn syntax(&self) -> &SyntaxToken {
1843 &self.syntax
1844 }
1845}
1846#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1847pub struct ImplKw {
1848 pub(crate) syntax: SyntaxToken,
1849}
1850impl std::fmt::Display for ImplKw {
1851 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1852 std::fmt::Display::fmt(&self.syntax, f)
1853 }
1854}
1855impl AstToken for ImplKw {
1856 fn can_cast(kind: SyntaxKind) -> bool {
1857 match kind {
1858 IMPL_KW => true,
1859 _ => false,
1860 }
1861 }
1862 fn cast(syntax: SyntaxToken) -> Option<Self> {
1863 if Self::can_cast(syntax.kind()) {
1864 Some(Self { syntax })
1865 } else {
1866 None
1867 }
1868 }
1869 fn syntax(&self) -> &SyntaxToken {
1870 &self.syntax
1871 }
1872}
1873#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1874pub struct InKw {
1875 pub(crate) syntax: SyntaxToken,
1876}
1877impl std::fmt::Display for InKw {
1878 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1879 std::fmt::Display::fmt(&self.syntax, f)
1880 }
1881}
1882impl AstToken for InKw {
1883 fn can_cast(kind: SyntaxKind) -> bool {
1884 match kind {
1885 IN_KW => true,
1886 _ => false,
1887 }
1888 }
1889 fn cast(syntax: SyntaxToken) -> Option<Self> {
1890 if Self::can_cast(syntax.kind()) {
1891 Some(Self { syntax })
1892 } else {
1893 None
1894 }
1895 }
1896 fn syntax(&self) -> &SyntaxToken {
1897 &self.syntax
1898 }
1899}
1900#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1901pub struct LetKw {
1902 pub(crate) syntax: SyntaxToken,
1903}
1904impl std::fmt::Display for LetKw {
1905 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1906 std::fmt::Display::fmt(&self.syntax, f)
1907 }
1908}
1909impl AstToken for LetKw {
1910 fn can_cast(kind: SyntaxKind) -> bool {
1911 match kind {
1912 LET_KW => true,
1913 _ => false,
1914 }
1915 }
1916 fn cast(syntax: SyntaxToken) -> Option<Self> {
1917 if Self::can_cast(syntax.kind()) {
1918 Some(Self { syntax })
1919 } else {
1920 None
1921 }
1922 }
1923 fn syntax(&self) -> &SyntaxToken {
1924 &self.syntax
1925 }
1926}
1927#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1928pub struct LoopKw {
1929 pub(crate) syntax: SyntaxToken,
1930}
1931impl std::fmt::Display for LoopKw {
1932 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1933 std::fmt::Display::fmt(&self.syntax, f)
1934 }
1935}
1936impl AstToken for LoopKw {
1937 fn can_cast(kind: SyntaxKind) -> bool {
1938 match kind {
1939 LOOP_KW => true,
1940 _ => false,
1941 }
1942 }
1943 fn cast(syntax: SyntaxToken) -> Option<Self> {
1944 if Self::can_cast(syntax.kind()) {
1945 Some(Self { syntax })
1946 } else {
1947 None
1948 }
1949 }
1950 fn syntax(&self) -> &SyntaxToken {
1951 &self.syntax
1952 }
1953}
1954#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1955pub struct MacroKw {
1956 pub(crate) syntax: SyntaxToken,
1957}
1958impl std::fmt::Display for MacroKw {
1959 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1960 std::fmt::Display::fmt(&self.syntax, f)
1961 }
1962}
1963impl AstToken for MacroKw {
1964 fn can_cast(kind: SyntaxKind) -> bool {
1965 match kind {
1966 MACRO_KW => true,
1967 _ => false,
1968 }
1969 }
1970 fn cast(syntax: SyntaxToken) -> Option<Self> {
1971 if Self::can_cast(syntax.kind()) {
1972 Some(Self { syntax })
1973 } else {
1974 None
1975 }
1976 }
1977 fn syntax(&self) -> &SyntaxToken {
1978 &self.syntax
1979 }
1980}
1981#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1982pub struct MatchKw {
1983 pub(crate) syntax: SyntaxToken,
1984}
1985impl std::fmt::Display for MatchKw {
1986 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1987 std::fmt::Display::fmt(&self.syntax, f)
1988 }
1989}
1990impl AstToken for MatchKw {
1991 fn can_cast(kind: SyntaxKind) -> bool {
1992 match kind {
1993 MATCH_KW => true,
1994 _ => false,
1995 }
1996 }
1997 fn cast(syntax: SyntaxToken) -> Option<Self> {
1998 if Self::can_cast(syntax.kind()) {
1999 Some(Self { syntax })
2000 } else {
2001 None
2002 }
2003 }
2004 fn syntax(&self) -> &SyntaxToken {
2005 &self.syntax
2006 }
2007}
2008#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2009pub struct ModKw {
2010 pub(crate) syntax: SyntaxToken,
2011}
2012impl std::fmt::Display for ModKw {
2013 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2014 std::fmt::Display::fmt(&self.syntax, f)
2015 }
2016}
2017impl AstToken for ModKw {
2018 fn can_cast(kind: SyntaxKind) -> bool {
2019 match kind {
2020 MOD_KW => true,
2021 _ => false,
2022 }
2023 }
2024 fn cast(syntax: SyntaxToken) -> Option<Self> {
2025 if Self::can_cast(syntax.kind()) {
2026 Some(Self { syntax })
2027 } else {
2028 None
2029 }
2030 }
2031 fn syntax(&self) -> &SyntaxToken {
2032 &self.syntax
2033 }
2034}
2035#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2036pub struct MoveKw {
2037 pub(crate) syntax: SyntaxToken,
2038}
2039impl std::fmt::Display for MoveKw {
2040 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2041 std::fmt::Display::fmt(&self.syntax, f)
2042 }
2043}
2044impl AstToken for MoveKw {
2045 fn can_cast(kind: SyntaxKind) -> bool {
2046 match kind {
2047 MOVE_KW => true,
2048 _ => false,
2049 }
2050 }
2051 fn cast(syntax: SyntaxToken) -> Option<Self> {
2052 if Self::can_cast(syntax.kind()) {
2053 Some(Self { syntax })
2054 } else {
2055 None
2056 }
2057 }
2058 fn syntax(&self) -> &SyntaxToken {
2059 &self.syntax
2060 }
2061}
2062#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2063pub struct MutKw {
2064 pub(crate) syntax: SyntaxToken,
2065}
2066impl std::fmt::Display for MutKw {
2067 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2068 std::fmt::Display::fmt(&self.syntax, f)
2069 }
2070}
2071impl AstToken for MutKw {
2072 fn can_cast(kind: SyntaxKind) -> bool {
2073 match kind {
2074 MUT_KW => true,
2075 _ => false,
2076 }
2077 }
2078 fn cast(syntax: SyntaxToken) -> Option<Self> {
2079 if Self::can_cast(syntax.kind()) {
2080 Some(Self { syntax })
2081 } else {
2082 None
2083 }
2084 }
2085 fn syntax(&self) -> &SyntaxToken {
2086 &self.syntax
2087 }
2088}
2089#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2090pub struct PubKw {
2091 pub(crate) syntax: SyntaxToken,
2092}
2093impl std::fmt::Display for PubKw {
2094 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2095 std::fmt::Display::fmt(&self.syntax, f)
2096 }
2097}
2098impl AstToken for PubKw {
2099 fn can_cast(kind: SyntaxKind) -> bool {
2100 match kind {
2101 PUB_KW => true,
2102 _ => false,
2103 }
2104 }
2105 fn cast(syntax: SyntaxToken) -> Option<Self> {
2106 if Self::can_cast(syntax.kind()) {
2107 Some(Self { syntax })
2108 } else {
2109 None
2110 }
2111 }
2112 fn syntax(&self) -> &SyntaxToken {
2113 &self.syntax
2114 }
2115}
2116#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2117pub struct RefKw {
2118 pub(crate) syntax: SyntaxToken,
2119}
2120impl std::fmt::Display for RefKw {
2121 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2122 std::fmt::Display::fmt(&self.syntax, f)
2123 }
2124}
2125impl AstToken for RefKw {
2126 fn can_cast(kind: SyntaxKind) -> bool {
2127 match kind {
2128 REF_KW => true,
2129 _ => false,
2130 }
2131 }
2132 fn cast(syntax: SyntaxToken) -> Option<Self> {
2133 if Self::can_cast(syntax.kind()) {
2134 Some(Self { syntax })
2135 } else {
2136 None
2137 }
2138 }
2139 fn syntax(&self) -> &SyntaxToken {
2140 &self.syntax
2141 }
2142}
2143#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2144pub struct ReturnKw {
2145 pub(crate) syntax: SyntaxToken,
2146}
2147impl std::fmt::Display for ReturnKw {
2148 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2149 std::fmt::Display::fmt(&self.syntax, f)
2150 }
2151}
2152impl AstToken for ReturnKw {
2153 fn can_cast(kind: SyntaxKind) -> bool {
2154 match kind {
2155 RETURN_KW => true,
2156 _ => false,
2157 }
2158 }
2159 fn cast(syntax: SyntaxToken) -> Option<Self> {
2160 if Self::can_cast(syntax.kind()) {
2161 Some(Self { syntax })
2162 } else {
2163 None
2164 }
2165 }
2166 fn syntax(&self) -> &SyntaxToken {
2167 &self.syntax
2168 }
2169}
2170#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2171pub struct SelfKw {
2172 pub(crate) syntax: SyntaxToken,
2173}
2174impl std::fmt::Display for SelfKw {
2175 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2176 std::fmt::Display::fmt(&self.syntax, f)
2177 }
2178}
2179impl AstToken for SelfKw {
2180 fn can_cast(kind: SyntaxKind) -> bool {
2181 match kind {
2182 SELF_KW => true,
2183 _ => false,
2184 }
2185 }
2186 fn cast(syntax: SyntaxToken) -> Option<Self> {
2187 if Self::can_cast(syntax.kind()) {
2188 Some(Self { syntax })
2189 } else {
2190 None
2191 }
2192 }
2193 fn syntax(&self) -> &SyntaxToken {
2194 &self.syntax
2195 }
2196}
2197#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2198pub struct StaticKw {
2199 pub(crate) syntax: SyntaxToken,
2200}
2201impl std::fmt::Display for StaticKw {
2202 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2203 std::fmt::Display::fmt(&self.syntax, f)
2204 }
2205}
2206impl AstToken for StaticKw {
2207 fn can_cast(kind: SyntaxKind) -> bool {
2208 match kind {
2209 STATIC_KW => true,
2210 _ => false,
2211 }
2212 }
2213 fn cast(syntax: SyntaxToken) -> Option<Self> {
2214 if Self::can_cast(syntax.kind()) {
2215 Some(Self { syntax })
2216 } else {
2217 None
2218 }
2219 }
2220 fn syntax(&self) -> &SyntaxToken {
2221 &self.syntax
2222 }
2223}
2224#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2225pub struct StructKw {
2226 pub(crate) syntax: SyntaxToken,
2227}
2228impl std::fmt::Display for StructKw {
2229 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2230 std::fmt::Display::fmt(&self.syntax, f)
2231 }
2232}
2233impl AstToken for StructKw {
2234 fn can_cast(kind: SyntaxKind) -> bool {
2235 match kind {
2236 STRUCT_KW => true,
2237 _ => false,
2238 }
2239 }
2240 fn cast(syntax: SyntaxToken) -> Option<Self> {
2241 if Self::can_cast(syntax.kind()) {
2242 Some(Self { syntax })
2243 } else {
2244 None
2245 }
2246 }
2247 fn syntax(&self) -> &SyntaxToken {
2248 &self.syntax
2249 }
2250}
2251#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2252pub struct SuperKw {
2253 pub(crate) syntax: SyntaxToken,
2254}
2255impl std::fmt::Display for SuperKw {
2256 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2257 std::fmt::Display::fmt(&self.syntax, f)
2258 }
2259}
2260impl AstToken for SuperKw {
2261 fn can_cast(kind: SyntaxKind) -> bool {
2262 match kind {
2263 SUPER_KW => true,
2264 _ => false,
2265 }
2266 }
2267 fn cast(syntax: SyntaxToken) -> Option<Self> {
2268 if Self::can_cast(syntax.kind()) {
2269 Some(Self { syntax })
2270 } else {
2271 None
2272 }
2273 }
2274 fn syntax(&self) -> &SyntaxToken {
2275 &self.syntax
2276 }
2277}
2278#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2279pub struct TraitKw {
2280 pub(crate) syntax: SyntaxToken,
2281}
2282impl std::fmt::Display for TraitKw {
2283 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2284 std::fmt::Display::fmt(&self.syntax, f)
2285 }
2286}
2287impl AstToken for TraitKw {
2288 fn can_cast(kind: SyntaxKind) -> bool {
2289 match kind {
2290 TRAIT_KW => true,
2291 _ => false,
2292 }
2293 }
2294 fn cast(syntax: SyntaxToken) -> Option<Self> {
2295 if Self::can_cast(syntax.kind()) {
2296 Some(Self { syntax })
2297 } else {
2298 None
2299 }
2300 }
2301 fn syntax(&self) -> &SyntaxToken {
2302 &self.syntax
2303 }
2304}
2305#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2306pub struct TrueKw {
2307 pub(crate) syntax: SyntaxToken,
2308}
2309impl std::fmt::Display for TrueKw {
2310 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2311 std::fmt::Display::fmt(&self.syntax, f)
2312 }
2313}
2314impl AstToken for TrueKw {
2315 fn can_cast(kind: SyntaxKind) -> bool {
2316 match kind {
2317 TRUE_KW => true,
2318 _ => false,
2319 }
2320 }
2321 fn cast(syntax: SyntaxToken) -> Option<Self> {
2322 if Self::can_cast(syntax.kind()) {
2323 Some(Self { syntax })
2324 } else {
2325 None
2326 }
2327 }
2328 fn syntax(&self) -> &SyntaxToken {
2329 &self.syntax
2330 }
2331}
2332#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2333pub struct TryKw {
2334 pub(crate) syntax: SyntaxToken,
2335}
2336impl std::fmt::Display for TryKw {
2337 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2338 std::fmt::Display::fmt(&self.syntax, f)
2339 }
2340}
2341impl AstToken for TryKw {
2342 fn can_cast(kind: SyntaxKind) -> bool {
2343 match kind {
2344 TRY_KW => true,
2345 _ => false,
2346 }
2347 }
2348 fn cast(syntax: SyntaxToken) -> Option<Self> {
2349 if Self::can_cast(syntax.kind()) {
2350 Some(Self { syntax })
2351 } else {
2352 None
2353 }
2354 }
2355 fn syntax(&self) -> &SyntaxToken {
2356 &self.syntax
2357 }
2358}
2359#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2360pub struct TypeKw {
2361 pub(crate) syntax: SyntaxToken,
2362}
2363impl std::fmt::Display for TypeKw {
2364 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2365 std::fmt::Display::fmt(&self.syntax, f)
2366 }
2367}
2368impl AstToken for TypeKw {
2369 fn can_cast(kind: SyntaxKind) -> bool {
2370 match kind {
2371 TYPE_KW => true,
2372 _ => false,
2373 }
2374 }
2375 fn cast(syntax: SyntaxToken) -> Option<Self> {
2376 if Self::can_cast(syntax.kind()) {
2377 Some(Self { syntax })
2378 } else {
2379 None
2380 }
2381 }
2382 fn syntax(&self) -> &SyntaxToken {
2383 &self.syntax
2384 }
2385}
2386#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2387pub struct UnsafeKw {
2388 pub(crate) syntax: SyntaxToken,
2389}
2390impl std::fmt::Display for UnsafeKw {
2391 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2392 std::fmt::Display::fmt(&self.syntax, f)
2393 }
2394}
2395impl AstToken for UnsafeKw {
2396 fn can_cast(kind: SyntaxKind) -> bool {
2397 match kind {
2398 UNSAFE_KW => true,
2399 _ => false,
2400 }
2401 }
2402 fn cast(syntax: SyntaxToken) -> Option<Self> {
2403 if Self::can_cast(syntax.kind()) {
2404 Some(Self { syntax })
2405 } else {
2406 None
2407 }
2408 }
2409 fn syntax(&self) -> &SyntaxToken {
2410 &self.syntax
2411 }
2412}
2413#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2414pub struct UseKw {
2415 pub(crate) syntax: SyntaxToken,
2416}
2417impl std::fmt::Display for UseKw {
2418 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2419 std::fmt::Display::fmt(&self.syntax, f)
2420 }
2421}
2422impl AstToken for UseKw {
2423 fn can_cast(kind: SyntaxKind) -> bool {
2424 match kind {
2425 USE_KW => true,
2426 _ => false,
2427 }
2428 }
2429 fn cast(syntax: SyntaxToken) -> Option<Self> {
2430 if Self::can_cast(syntax.kind()) {
2431 Some(Self { syntax })
2432 } else {
2433 None
2434 }
2435 }
2436 fn syntax(&self) -> &SyntaxToken {
2437 &self.syntax
2438 }
2439}
2440#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2441pub struct WhereKw {
2442 pub(crate) syntax: SyntaxToken,
2443}
2444impl std::fmt::Display for WhereKw {
2445 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2446 std::fmt::Display::fmt(&self.syntax, f)
2447 }
2448}
2449impl AstToken for WhereKw {
2450 fn can_cast(kind: SyntaxKind) -> bool {
2451 match kind {
2452 WHERE_KW => true,
2453 _ => false,
2454 }
2455 }
2456 fn cast(syntax: SyntaxToken) -> Option<Self> {
2457 if Self::can_cast(syntax.kind()) {
2458 Some(Self { syntax })
2459 } else {
2460 None
2461 }
2462 }
2463 fn syntax(&self) -> &SyntaxToken {
2464 &self.syntax
2465 }
2466}
2467#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2468pub struct WhileKw {
2469 pub(crate) syntax: SyntaxToken,
2470}
2471impl std::fmt::Display for WhileKw {
2472 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2473 std::fmt::Display::fmt(&self.syntax, f)
2474 }
2475}
2476impl AstToken for WhileKw {
2477 fn can_cast(kind: SyntaxKind) -> bool {
2478 match kind {
2479 WHILE_KW => true,
2480 _ => false,
2481 }
2482 }
2483 fn cast(syntax: SyntaxToken) -> Option<Self> {
2484 if Self::can_cast(syntax.kind()) {
2485 Some(Self { syntax })
2486 } else {
2487 None
2488 }
2489 }
2490 fn syntax(&self) -> &SyntaxToken {
2491 &self.syntax
2492 }
2493}
2494#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2495pub struct AutoKw {
2496 pub(crate) syntax: SyntaxToken,
2497}
2498impl std::fmt::Display for AutoKw {
2499 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2500 std::fmt::Display::fmt(&self.syntax, f)
2501 }
2502}
2503impl AstToken for AutoKw {
2504 fn can_cast(kind: SyntaxKind) -> bool {
2505 match kind {
2506 AUTO_KW => true,
2507 _ => false,
2508 }
2509 }
2510 fn cast(syntax: SyntaxToken) -> Option<Self> {
2511 if Self::can_cast(syntax.kind()) {
2512 Some(Self { syntax })
2513 } else {
2514 None
2515 }
2516 }
2517 fn syntax(&self) -> &SyntaxToken {
2518 &self.syntax
2519 }
2520}
2521#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2522pub struct DefaultKw {
2523 pub(crate) syntax: SyntaxToken,
2524}
2525impl std::fmt::Display for DefaultKw {
2526 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2527 std::fmt::Display::fmt(&self.syntax, f)
2528 }
2529}
2530impl AstToken for DefaultKw {
2531 fn can_cast(kind: SyntaxKind) -> bool {
2532 match kind {
2533 DEFAULT_KW => true,
2534 _ => false,
2535 }
2536 }
2537 fn cast(syntax: SyntaxToken) -> Option<Self> {
2538 if Self::can_cast(syntax.kind()) {
2539 Some(Self { syntax })
2540 } else {
2541 None
2542 }
2543 }
2544 fn syntax(&self) -> &SyntaxToken {
2545 &self.syntax
2546 }
2547}
2548#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2549pub struct ExistentialKw {
2550 pub(crate) syntax: SyntaxToken,
2551}
2552impl std::fmt::Display for ExistentialKw {
2553 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2554 std::fmt::Display::fmt(&self.syntax, f)
2555 }
2556}
2557impl AstToken for ExistentialKw {
2558 fn can_cast(kind: SyntaxKind) -> bool {
2559 match kind {
2560 EXISTENTIAL_KW => true,
2561 _ => false,
2562 }
2563 }
2564 fn cast(syntax: SyntaxToken) -> Option<Self> {
2565 if Self::can_cast(syntax.kind()) {
2566 Some(Self { syntax })
2567 } else {
2568 None
2569 }
2570 }
2571 fn syntax(&self) -> &SyntaxToken {
2572 &self.syntax
2573 }
2574}
2575#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2576pub struct UnionKw {
2577 pub(crate) syntax: SyntaxToken,
2578}
2579impl std::fmt::Display for UnionKw {
2580 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2581 std::fmt::Display::fmt(&self.syntax, f)
2582 }
2583}
2584impl AstToken for UnionKw {
2585 fn can_cast(kind: SyntaxKind) -> bool {
2586 match kind {
2587 UNION_KW => true,
2588 _ => false,
2589 }
2590 }
2591 fn cast(syntax: SyntaxToken) -> Option<Self> {
2592 if Self::can_cast(syntax.kind()) {
2593 Some(Self { syntax })
2594 } else {
2595 None
2596 }
2597 }
2598 fn syntax(&self) -> &SyntaxToken {
2599 &self.syntax
2600 }
2601}
2602#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2603pub struct RawKw {
2604 pub(crate) syntax: SyntaxToken,
2605}
2606impl std::fmt::Display for RawKw {
2607 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2608 std::fmt::Display::fmt(&self.syntax, f)
2609 }
2610}
2611impl AstToken for RawKw {
2612 fn can_cast(kind: SyntaxKind) -> bool {
2613 match kind {
2614 RAW_KW => true,
2615 _ => false,
2616 }
2617 }
2618 fn cast(syntax: SyntaxToken) -> Option<Self> {
2619 if Self::can_cast(syntax.kind()) {
2620 Some(Self { syntax })
2621 } else {
2622 None
2623 }
2624 }
2625 fn syntax(&self) -> &SyntaxToken {
2626 &self.syntax
2627 }
2628}
2629#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2630pub struct IntNumber {
2631 pub(crate) syntax: SyntaxToken,
2632}
2633impl std::fmt::Display for IntNumber {
2634 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2635 std::fmt::Display::fmt(&self.syntax, f)
2636 }
2637}
2638impl AstToken for IntNumber {
2639 fn can_cast(kind: SyntaxKind) -> bool {
2640 match kind {
2641 INT_NUMBER => true,
2642 _ => false,
2643 }
2644 }
2645 fn cast(syntax: SyntaxToken) -> Option<Self> {
2646 if Self::can_cast(syntax.kind()) {
2647 Some(Self { syntax })
2648 } else {
2649 None
2650 }
2651 }
2652 fn syntax(&self) -> &SyntaxToken {
2653 &self.syntax
2654 }
2655}
2656#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2657pub struct FloatNumber {
2658 pub(crate) syntax: SyntaxToken,
2659}
2660impl std::fmt::Display for FloatNumber {
2661 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2662 std::fmt::Display::fmt(&self.syntax, f)
2663 }
2664}
2665impl AstToken for FloatNumber {
2666 fn can_cast(kind: SyntaxKind) -> bool {
2667 match kind {
2668 FLOAT_NUMBER => true,
2669 _ => false,
2670 }
2671 }
2672 fn cast(syntax: SyntaxToken) -> Option<Self> {
2673 if Self::can_cast(syntax.kind()) {
2674 Some(Self { syntax })
2675 } else {
2676 None
2677 }
2678 }
2679 fn syntax(&self) -> &SyntaxToken {
2680 &self.syntax
2681 }
2682}
2683#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2684pub struct Char {
2685 pub(crate) syntax: SyntaxToken,
2686}
2687impl std::fmt::Display for Char {
2688 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2689 std::fmt::Display::fmt(&self.syntax, f)
2690 }
2691}
2692impl AstToken for Char {
2693 fn can_cast(kind: SyntaxKind) -> bool {
2694 match kind {
2695 CHAR => true,
2696 _ => false,
2697 }
2698 }
2699 fn cast(syntax: SyntaxToken) -> Option<Self> {
2700 if Self::can_cast(syntax.kind()) {
2701 Some(Self { syntax })
2702 } else {
2703 None
2704 }
2705 }
2706 fn syntax(&self) -> &SyntaxToken {
2707 &self.syntax
2708 }
2709}
2710#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2711pub struct Byte {
2712 pub(crate) syntax: SyntaxToken,
2713}
2714impl std::fmt::Display for Byte {
2715 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2716 std::fmt::Display::fmt(&self.syntax, f)
2717 }
2718}
2719impl AstToken for Byte {
2720 fn can_cast(kind: SyntaxKind) -> bool {
2721 match kind {
2722 BYTE => true,
2723 _ => false,
2724 }
2725 }
2726 fn cast(syntax: SyntaxToken) -> Option<Self> {
2727 if Self::can_cast(syntax.kind()) {
2728 Some(Self { syntax })
2729 } else {
2730 None
2731 }
2732 }
2733 fn syntax(&self) -> &SyntaxToken {
2734 &self.syntax
2735 }
2736}
2737#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2738pub struct String {
2739 pub(crate) syntax: SyntaxToken,
2740}
2741impl std::fmt::Display for String {
2742 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2743 std::fmt::Display::fmt(&self.syntax, f)
2744 }
2745}
2746impl AstToken for String {
2747 fn can_cast(kind: SyntaxKind) -> bool {
2748 match kind {
2749 STRING => true,
2750 _ => false,
2751 }
2752 }
2753 fn cast(syntax: SyntaxToken) -> Option<Self> {
2754 if Self::can_cast(syntax.kind()) {
2755 Some(Self { syntax })
2756 } else {
2757 None
2758 }
2759 }
2760 fn syntax(&self) -> &SyntaxToken {
2761 &self.syntax
2762 }
2763}
2764#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2765pub struct RawString {
2766 pub(crate) syntax: SyntaxToken,
2767}
2768impl std::fmt::Display for RawString {
2769 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2770 std::fmt::Display::fmt(&self.syntax, f)
2771 }
2772}
2773impl AstToken for RawString {
2774 fn can_cast(kind: SyntaxKind) -> bool {
2775 match kind {
2776 RAW_STRING => true,
2777 _ => false,
2778 }
2779 }
2780 fn cast(syntax: SyntaxToken) -> Option<Self> {
2781 if Self::can_cast(syntax.kind()) {
2782 Some(Self { syntax })
2783 } else {
2784 None
2785 }
2786 }
2787 fn syntax(&self) -> &SyntaxToken {
2788 &self.syntax
2789 }
2790}
2791#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2792pub struct ByteString {
2793 pub(crate) syntax: SyntaxToken,
2794}
2795impl std::fmt::Display for ByteString {
2796 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2797 std::fmt::Display::fmt(&self.syntax, f)
2798 }
2799}
2800impl AstToken for ByteString {
2801 fn can_cast(kind: SyntaxKind) -> bool {
2802 match kind {
2803 BYTE_STRING => true,
2804 _ => false,
2805 }
2806 }
2807 fn cast(syntax: SyntaxToken) -> Option<Self> {
2808 if Self::can_cast(syntax.kind()) {
2809 Some(Self { syntax })
2810 } else {
2811 None
2812 }
2813 }
2814 fn syntax(&self) -> &SyntaxToken {
2815 &self.syntax
2816 }
2817}
2818#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2819pub struct RawByteString {
2820 pub(crate) syntax: SyntaxToken,
2821}
2822impl std::fmt::Display for RawByteString {
2823 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2824 std::fmt::Display::fmt(&self.syntax, f)
2825 }
2826}
2827impl AstToken for RawByteString {
2828 fn can_cast(kind: SyntaxKind) -> bool {
2829 match kind {
2830 RAW_BYTE_STRING => true,
2831 _ => false,
2832 }
2833 }
2834 fn cast(syntax: SyntaxToken) -> Option<Self> {
2835 if Self::can_cast(syntax.kind()) {
2836 Some(Self { syntax })
2837 } else {
2838 None
2839 }
2840 }
2841 fn syntax(&self) -> &SyntaxToken {
2842 &self.syntax
2843 }
2844}
2845#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2846pub struct Error {
2847 pub(crate) syntax: SyntaxToken,
2848}
2849impl std::fmt::Display for Error {
2850 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2851 std::fmt::Display::fmt(&self.syntax, f)
2852 }
2853}
2854impl AstToken for Error {
2855 fn can_cast(kind: SyntaxKind) -> bool {
2856 match kind {
2857 ERROR => true,
2858 _ => false,
2859 }
2860 }
2861 fn cast(syntax: SyntaxToken) -> Option<Self> {
2862 if Self::can_cast(syntax.kind()) {
2863 Some(Self { syntax })
2864 } else {
2865 None
2866 }
2867 }
2868 fn syntax(&self) -> &SyntaxToken {
2869 &self.syntax
2870 }
2871}
2872#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2873pub struct Ident {
2874 pub(crate) syntax: SyntaxToken,
2875}
2876impl std::fmt::Display for Ident {
2877 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2878 std::fmt::Display::fmt(&self.syntax, f)
2879 }
2880}
2881impl AstToken for Ident {
2882 fn can_cast(kind: SyntaxKind) -> bool {
2883 match kind {
2884 IDENT => true,
2885 _ => false,
2886 }
2887 }
2888 fn cast(syntax: SyntaxToken) -> Option<Self> {
2889 if Self::can_cast(syntax.kind()) {
2890 Some(Self { syntax })
2891 } else {
2892 None
2893 }
2894 }
2895 fn syntax(&self) -> &SyntaxToken {
2896 &self.syntax
2897 }
2898}
2899#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2900pub struct Whitespace {
2901 pub(crate) syntax: SyntaxToken,
2902}
2903impl std::fmt::Display for Whitespace {
2904 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2905 std::fmt::Display::fmt(&self.syntax, f)
2906 }
2907}
2908impl AstToken for Whitespace {
2909 fn can_cast(kind: SyntaxKind) -> bool {
2910 match kind {
2911 WHITESPACE => true,
2912 _ => false,
2913 }
2914 }
2915 fn cast(syntax: SyntaxToken) -> Option<Self> {
2916 if Self::can_cast(syntax.kind()) {
2917 Some(Self { syntax })
2918 } else {
2919 None
2920 }
2921 }
2922 fn syntax(&self) -> &SyntaxToken {
2923 &self.syntax
2924 }
2925}
2926#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2927pub struct Lifetime {
2928 pub(crate) syntax: SyntaxToken,
2929}
2930impl std::fmt::Display for Lifetime {
2931 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2932 std::fmt::Display::fmt(&self.syntax, f)
2933 }
2934}
2935impl AstToken for Lifetime {
2936 fn can_cast(kind: SyntaxKind) -> bool {
2937 match kind {
2938 LIFETIME => true,
2939 _ => false,
2940 }
2941 }
2942 fn cast(syntax: SyntaxToken) -> Option<Self> {
2943 if Self::can_cast(syntax.kind()) {
2944 Some(Self { syntax })
2945 } else {
2946 None
2947 }
2948 }
2949 fn syntax(&self) -> &SyntaxToken {
2950 &self.syntax
2951 }
2952}
2953#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2954pub struct Comment {
2955 pub(crate) syntax: SyntaxToken,
2956}
2957impl std::fmt::Display for Comment {
2958 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2959 std::fmt::Display::fmt(&self.syntax, f)
2960 }
2961}
2962impl AstToken for Comment {
2963 fn can_cast(kind: SyntaxKind) -> bool {
2964 match kind {
2965 COMMENT => true,
2966 _ => false,
2967 }
2968 }
2969 fn cast(syntax: SyntaxToken) -> Option<Self> {
2970 if Self::can_cast(syntax.kind()) {
2971 Some(Self { syntax })
2972 } else {
2973 None
2974 }
2975 }
2976 fn syntax(&self) -> &SyntaxToken {
2977 &self.syntax
2978 }
2979}
2980#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2981pub struct Shebang {
2982 pub(crate) syntax: SyntaxToken,
2983}
2984impl std::fmt::Display for Shebang {
2985 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2986 std::fmt::Display::fmt(&self.syntax, f)
2987 }
2988}
2989impl AstToken for Shebang {
2990 fn can_cast(kind: SyntaxKind) -> bool {
2991 match kind {
2992 SHEBANG => true,
2993 _ => false,
2994 }
2995 }
2996 fn cast(syntax: SyntaxToken) -> Option<Self> {
2997 if Self::can_cast(syntax.kind()) {
2998 Some(Self { syntax })
2999 } else {
3000 None
3001 }
3002 }
3003 fn syntax(&self) -> &SyntaxToken {
3004 &self.syntax
3005 }
3006}
3007#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3008pub struct LDollar {
3009 pub(crate) syntax: SyntaxToken,
3010}
3011impl std::fmt::Display for LDollar {
3012 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3013 std::fmt::Display::fmt(&self.syntax, f)
3014 }
3015}
3016impl AstToken for LDollar {
3017 fn can_cast(kind: SyntaxKind) -> bool {
3018 match kind {
3019 L_DOLLAR => true,
3020 _ => false,
3021 }
3022 }
3023 fn cast(syntax: SyntaxToken) -> Option<Self> {
3024 if Self::can_cast(syntax.kind()) {
3025 Some(Self { syntax })
3026 } else {
3027 None
3028 }
3029 }
3030 fn syntax(&self) -> &SyntaxToken {
3031 &self.syntax
3032 }
3033}
3034#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3035pub struct RDollar {
3036 pub(crate) syntax: SyntaxToken,
3037}
3038impl std::fmt::Display for RDollar {
3039 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3040 std::fmt::Display::fmt(&self.syntax, f)
3041 }
3042}
3043impl AstToken for RDollar {
3044 fn can_cast(kind: SyntaxKind) -> bool {
3045 match kind {
3046 R_DOLLAR => true,
3047 _ => false,
3048 }
3049 }
3050 fn cast(syntax: SyntaxToken) -> Option<Self> {
3051 if Self::can_cast(syntax.kind()) {
3052 Some(Self { syntax })
3053 } else {
3054 None
3055 }
3056 }
3057 fn syntax(&self) -> &SyntaxToken {
3058 &self.syntax
3059 }
3060}
3061#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3062pub struct SourceFile {
3063 pub(crate) syntax: SyntaxNode,
3064}
3065impl std::fmt::Display for SourceFile {
3066 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3067 std::fmt::Display::fmt(self.syntax(), f)
3068 }
3069}
3070impl AstNode for SourceFile {
3071 fn can_cast(kind: SyntaxKind) -> bool {
3072 match kind {
3073 SOURCE_FILE => true,
3074 _ => false,
3075 }
3076 }
3077 fn cast(syntax: SyntaxNode) -> Option<Self> {
3078 if Self::can_cast(syntax.kind()) {
3079 Some(Self { syntax })
3080 } else {
3081 None
3082 }
3083 }
3084 fn syntax(&self) -> &SyntaxNode {
3085 &self.syntax
3086 }
3087}
3088impl ast::ModuleItemOwner for SourceFile {}
3089impl ast::FnDefOwner for SourceFile {}
3090impl ast::AttrsOwner for SourceFile {}
3091impl SourceFile {
3092 pub fn modules(&self) -> AstChildren<Module> {
3093 support::children(&self.syntax)
3094 }
3095}
3096#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3097pub struct FnDef {
3098 pub(crate) syntax: SyntaxNode,
3099}
3100impl std::fmt::Display for FnDef {
3101 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3102 std::fmt::Display::fmt(self.syntax(), f)
3103 }
3104}
3105impl AstNode for FnDef {
3106 fn can_cast(kind: SyntaxKind) -> bool {
3107 match kind {
3108 FN_DEF => true,
3109 _ => false,
3110 }
3111 }
3112 fn cast(syntax: SyntaxNode) -> Option<Self> {
3113 if Self::can_cast(syntax.kind()) {
3114 Some(Self { syntax })
3115 } else {
3116 None
3117 }
3118 }
3119 fn syntax(&self) -> &SyntaxNode {
3120 &self.syntax
3121 }
3122}
3123impl ast::VisibilityOwner for FnDef {}
3124impl ast::NameOwner for FnDef {}
3125impl ast::TypeParamsOwner for FnDef {}
3126impl ast::DocCommentsOwner for FnDef {}
3127impl ast::AttrsOwner for FnDef {}
3128impl FnDef {
3129 pub fn abi(&self) -> Option<Abi> {
3130 support::child(&self.syntax)
3131 }
3132 pub fn const_kw(&self) -> Option<ConstKw> {
3133 support::token(&self.syntax)
3134 }
3135 pub fn default_kw(&self) -> Option<DefaultKw> {
3136 support::token(&self.syntax)
3137 }
3138 pub fn async_kw(&self) -> Option<AsyncKw> {
3139 support::token(&self.syntax)
3140 }
3141 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
3142 support::token(&self.syntax)
3143 }
3144 pub fn fn_kw(&self) -> Option<FnKw> {
3145 support::token(&self.syntax)
3146 }
3147 pub fn param_list(&self) -> Option<ParamList> {
3148 support::child(&self.syntax)
3149 }
3150 pub fn ret_type(&self) -> Option<RetType> {
3151 support::child(&self.syntax)
3152 }
3153 pub fn body(&self) -> Option<BlockExpr> {
3154 support::child(&self.syntax)
3155 }
3156 pub fn semi(&self) -> Option<Semi> {
3157 support::token(&self.syntax)
3158 }
3159}
3160#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3161pub struct RetType {
3162 pub(crate) syntax: SyntaxNode,
3163}
3164impl std::fmt::Display for RetType {
3165 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3166 std::fmt::Display::fmt(self.syntax(), f)
3167 }
3168}
3169impl AstNode for RetType {
3170 fn can_cast(kind: SyntaxKind) -> bool {
3171 match kind {
3172 RET_TYPE => true,
3173 _ => false,
3174 }
3175 }
3176 fn cast(syntax: SyntaxNode) -> Option<Self> {
3177 if Self::can_cast(syntax.kind()) {
3178 Some(Self { syntax })
3179 } else {
3180 None
3181 }
3182 }
3183 fn syntax(&self) -> &SyntaxNode {
3184 &self.syntax
3185 }
3186}
3187impl RetType {
3188 pub fn thin_arrow(&self) -> Option<ThinArrow> {
3189 support::token(&self.syntax)
3190 }
3191 pub fn type_ref(&self) -> Option<TypeRef> {
3192 support::child(&self.syntax)
3193 }
3194}
3195#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3196pub struct StructDef {
3197 pub(crate) syntax: SyntaxNode,
3198}
3199impl std::fmt::Display for StructDef {
3200 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3201 std::fmt::Display::fmt(self.syntax(), f)
3202 }
3203}
3204impl AstNode for StructDef {
3205 fn can_cast(kind: SyntaxKind) -> bool {
3206 match kind {
3207 STRUCT_DEF => true,
3208 _ => false,
3209 }
3210 }
3211 fn cast(syntax: SyntaxNode) -> Option<Self> {
3212 if Self::can_cast(syntax.kind()) {
3213 Some(Self { syntax })
3214 } else {
3215 None
3216 }
3217 }
3218 fn syntax(&self) -> &SyntaxNode {
3219 &self.syntax
3220 }
3221}
3222impl ast::VisibilityOwner for StructDef {}
3223impl ast::NameOwner for StructDef {}
3224impl ast::TypeParamsOwner for StructDef {}
3225impl ast::AttrsOwner for StructDef {}
3226impl ast::DocCommentsOwner for StructDef {}
3227impl StructDef {
3228 pub fn struct_kw(&self) -> Option<StructKw> {
3229 support::token(&self.syntax)
3230 }
3231 pub fn field_def_list(&self) -> Option<FieldDefList> {
3232 support::child(&self.syntax)
3233 }
3234 pub fn semi(&self) -> Option<Semi> {
3235 support::token(&self.syntax)
3236 }
3237}
3238#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3239pub struct UnionDef {
3240 pub(crate) syntax: SyntaxNode,
3241}
3242impl std::fmt::Display for UnionDef {
3243 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3244 std::fmt::Display::fmt(self.syntax(), f)
3245 }
3246}
3247impl AstNode for UnionDef {
3248 fn can_cast(kind: SyntaxKind) -> bool {
3249 match kind {
3250 UNION_DEF => true,
3251 _ => false,
3252 }
3253 }
3254 fn cast(syntax: SyntaxNode) -> Option<Self> {
3255 if Self::can_cast(syntax.kind()) {
3256 Some(Self { syntax })
3257 } else {
3258 None
3259 }
3260 }
3261 fn syntax(&self) -> &SyntaxNode {
3262 &self.syntax
3263 }
3264}
3265impl ast::VisibilityOwner for UnionDef {}
3266impl ast::NameOwner for UnionDef {}
3267impl ast::TypeParamsOwner for UnionDef {}
3268impl ast::AttrsOwner for UnionDef {}
3269impl ast::DocCommentsOwner for UnionDef {}
3270impl UnionDef {
3271 pub fn union_kw(&self) -> Option<UnionKw> {
3272 support::token(&self.syntax)
3273 }
3274 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
3275 support::child(&self.syntax)
3276 }
3277}
3278#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3279pub struct RecordFieldDefList {
3280 pub(crate) syntax: SyntaxNode,
3281}
3282impl std::fmt::Display for RecordFieldDefList {
3283 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3284 std::fmt::Display::fmt(self.syntax(), f)
3285 }
3286}
3287impl AstNode for RecordFieldDefList {
3288 fn can_cast(kind: SyntaxKind) -> bool {
3289 match kind {
3290 RECORD_FIELD_DEF_LIST => true,
3291 _ => false,
3292 }
3293 }
3294 fn cast(syntax: SyntaxNode) -> Option<Self> {
3295 if Self::can_cast(syntax.kind()) {
3296 Some(Self { syntax })
3297 } else {
3298 None
3299 }
3300 }
3301 fn syntax(&self) -> &SyntaxNode {
3302 &self.syntax
3303 }
3304}
3305impl RecordFieldDefList {
3306 pub fn l_curly(&self) -> Option<LCurly> {
3307 support::token(&self.syntax)
3308 }
3309 pub fn fields(&self) -> AstChildren<RecordFieldDef> {
3310 support::children(&self.syntax)
3311 }
3312 pub fn r_curly(&self) -> Option<RCurly> {
3313 support::token(&self.syntax)
3314 }
3315}
3316#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3317pub struct RecordFieldDef {
3318 pub(crate) syntax: SyntaxNode,
3319}
3320impl std::fmt::Display for RecordFieldDef {
3321 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3322 std::fmt::Display::fmt(self.syntax(), f)
3323 }
3324}
3325impl AstNode for RecordFieldDef {
3326 fn can_cast(kind: SyntaxKind) -> bool {
3327 match kind {
3328 RECORD_FIELD_DEF => true,
3329 _ => false,
3330 }
3331 }
3332 fn cast(syntax: SyntaxNode) -> Option<Self> {
3333 if Self::can_cast(syntax.kind()) {
3334 Some(Self { syntax })
3335 } else {
3336 None
3337 }
3338 }
3339 fn syntax(&self) -> &SyntaxNode {
3340 &self.syntax
3341 }
3342}
3343impl ast::VisibilityOwner for RecordFieldDef {}
3344impl ast::NameOwner for RecordFieldDef {}
3345impl ast::AttrsOwner for RecordFieldDef {}
3346impl ast::DocCommentsOwner for RecordFieldDef {}
3347impl ast::TypeAscriptionOwner for RecordFieldDef {}
3348impl RecordFieldDef {}
3349#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3350pub struct TupleFieldDefList {
3351 pub(crate) syntax: SyntaxNode,
3352}
3353impl std::fmt::Display for TupleFieldDefList {
3354 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3355 std::fmt::Display::fmt(self.syntax(), f)
3356 }
3357}
3358impl AstNode for TupleFieldDefList {
3359 fn can_cast(kind: SyntaxKind) -> bool {
3360 match kind {
3361 TUPLE_FIELD_DEF_LIST => true,
3362 _ => false,
3363 }
3364 }
3365 fn cast(syntax: SyntaxNode) -> Option<Self> {
3366 if Self::can_cast(syntax.kind()) {
3367 Some(Self { syntax })
3368 } else {
3369 None
3370 }
3371 }
3372 fn syntax(&self) -> &SyntaxNode {
3373 &self.syntax
3374 }
3375}
3376impl TupleFieldDefList {
3377 pub fn l_paren(&self) -> Option<LParen> {
3378 support::token(&self.syntax)
3379 }
3380 pub fn fields(&self) -> AstChildren<TupleFieldDef> {
3381 support::children(&self.syntax)
3382 }
3383 pub fn r_paren(&self) -> Option<RParen> {
3384 support::token(&self.syntax)
3385 }
3386}
3387#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3388pub struct TupleFieldDef {
3389 pub(crate) syntax: SyntaxNode,
3390}
3391impl std::fmt::Display for TupleFieldDef {
3392 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3393 std::fmt::Display::fmt(self.syntax(), f)
3394 }
3395}
3396impl AstNode for TupleFieldDef {
3397 fn can_cast(kind: SyntaxKind) -> bool {
3398 match kind {
3399 TUPLE_FIELD_DEF => true,
3400 _ => false,
3401 }
3402 }
3403 fn cast(syntax: SyntaxNode) -> Option<Self> {
3404 if Self::can_cast(syntax.kind()) {
3405 Some(Self { syntax })
3406 } else {
3407 None
3408 }
3409 }
3410 fn syntax(&self) -> &SyntaxNode {
3411 &self.syntax
3412 }
3413}
3414impl ast::VisibilityOwner for TupleFieldDef {}
3415impl ast::AttrsOwner for TupleFieldDef {}
3416impl TupleFieldDef {
3417 pub fn type_ref(&self) -> Option<TypeRef> {
3418 support::child(&self.syntax)
3419 }
3420}
3421#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3422pub struct EnumDef {
3423 pub(crate) syntax: SyntaxNode,
3424}
3425impl std::fmt::Display for EnumDef {
3426 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3427 std::fmt::Display::fmt(self.syntax(), f)
3428 }
3429}
3430impl AstNode for EnumDef {
3431 fn can_cast(kind: SyntaxKind) -> bool {
3432 match kind {
3433 ENUM_DEF => true,
3434 _ => false,
3435 }
3436 }
3437 fn cast(syntax: SyntaxNode) -> Option<Self> {
3438 if Self::can_cast(syntax.kind()) {
3439 Some(Self { syntax })
3440 } else {
3441 None
3442 }
3443 }
3444 fn syntax(&self) -> &SyntaxNode {
3445 &self.syntax
3446 }
3447}
3448impl ast::VisibilityOwner for EnumDef {}
3449impl ast::NameOwner for EnumDef {}
3450impl ast::TypeParamsOwner for EnumDef {}
3451impl ast::AttrsOwner for EnumDef {}
3452impl ast::DocCommentsOwner for EnumDef {}
3453impl EnumDef {
3454 pub fn enum_kw(&self) -> Option<EnumKw> {
3455 support::token(&self.syntax)
3456 }
3457 pub fn variant_list(&self) -> Option<EnumVariantList> {
3458 support::child(&self.syntax)
3459 }
3460}
3461#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3462pub struct EnumVariantList {
3463 pub(crate) syntax: SyntaxNode,
3464}
3465impl std::fmt::Display for EnumVariantList {
3466 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3467 std::fmt::Display::fmt(self.syntax(), f)
3468 }
3469}
3470impl AstNode for EnumVariantList {
3471 fn can_cast(kind: SyntaxKind) -> bool {
3472 match kind {
3473 ENUM_VARIANT_LIST => true,
3474 _ => false,
3475 }
3476 }
3477 fn cast(syntax: SyntaxNode) -> Option<Self> {
3478 if Self::can_cast(syntax.kind()) {
3479 Some(Self { syntax })
3480 } else {
3481 None
3482 }
3483 }
3484 fn syntax(&self) -> &SyntaxNode {
3485 &self.syntax
3486 }
3487}
3488impl EnumVariantList {
3489 pub fn l_curly(&self) -> Option<LCurly> {
3490 support::token(&self.syntax)
3491 }
3492 pub fn variants(&self) -> AstChildren<EnumVariant> {
3493 support::children(&self.syntax)
3494 }
3495 pub fn r_curly(&self) -> Option<RCurly> {
3496 support::token(&self.syntax)
3497 }
3498}
3499#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3500pub struct EnumVariant {
3501 pub(crate) syntax: SyntaxNode,
3502}
3503impl std::fmt::Display for EnumVariant {
3504 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3505 std::fmt::Display::fmt(self.syntax(), f)
3506 }
3507}
3508impl AstNode for EnumVariant {
3509 fn can_cast(kind: SyntaxKind) -> bool {
3510 match kind {
3511 ENUM_VARIANT => true,
3512 _ => false,
3513 }
3514 }
3515 fn cast(syntax: SyntaxNode) -> Option<Self> {
3516 if Self::can_cast(syntax.kind()) {
3517 Some(Self { syntax })
3518 } else {
3519 None
3520 }
3521 }
3522 fn syntax(&self) -> &SyntaxNode {
3523 &self.syntax
3524 }
3525}
3526impl ast::VisibilityOwner for EnumVariant {}
3527impl ast::NameOwner for EnumVariant {}
3528impl ast::DocCommentsOwner for EnumVariant {}
3529impl ast::AttrsOwner for EnumVariant {}
3530impl EnumVariant {
3531 pub fn field_def_list(&self) -> Option<FieldDefList> {
3532 support::child(&self.syntax)
3533 }
3534 pub fn eq(&self) -> Option<Eq> {
3535 support::token(&self.syntax)
3536 }
3537 pub fn expr(&self) -> Option<Expr> {
3538 support::child(&self.syntax)
3539 }
3540}
3541#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3542pub struct TraitDef {
3543 pub(crate) syntax: SyntaxNode,
3544}
3545impl std::fmt::Display for TraitDef {
3546 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3547 std::fmt::Display::fmt(self.syntax(), f)
3548 }
3549}
3550impl AstNode for TraitDef {
3551 fn can_cast(kind: SyntaxKind) -> bool {
3552 match kind {
3553 TRAIT_DEF => true,
3554 _ => false,
3555 }
3556 }
3557 fn cast(syntax: SyntaxNode) -> Option<Self> {
3558 if Self::can_cast(syntax.kind()) {
3559 Some(Self { syntax })
3560 } else {
3561 None
3562 }
3563 }
3564 fn syntax(&self) -> &SyntaxNode {
3565 &self.syntax
3566 }
3567}
3568impl ast::VisibilityOwner for TraitDef {}
3569impl ast::NameOwner for TraitDef {}
3570impl ast::AttrsOwner for TraitDef {}
3571impl ast::DocCommentsOwner for TraitDef {}
3572impl ast::TypeParamsOwner for TraitDef {}
3573impl ast::TypeBoundsOwner for TraitDef {}
3574impl TraitDef {
3575 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
3576 support::token(&self.syntax)
3577 }
3578 pub fn auto_kw(&self) -> Option<AutoKw> {
3579 support::token(&self.syntax)
3580 }
3581 pub fn trait_kw(&self) -> Option<TraitKw> {
3582 support::token(&self.syntax)
3583 }
3584 pub fn item_list(&self) -> Option<ItemList> {
3585 support::child(&self.syntax)
3586 }
3587}
3588#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3589pub struct Module {
3590 pub(crate) syntax: SyntaxNode,
3591}
3592impl std::fmt::Display for Module {
3593 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3594 std::fmt::Display::fmt(self.syntax(), f)
3595 }
3596}
3597impl AstNode for Module {
3598 fn can_cast(kind: SyntaxKind) -> bool {
3599 match kind {
3600 MODULE => true,
3601 _ => false,
3602 }
3603 }
3604 fn cast(syntax: SyntaxNode) -> Option<Self> {
3605 if Self::can_cast(syntax.kind()) {
3606 Some(Self { syntax })
3607 } else {
3608 None
3609 }
3610 }
3611 fn syntax(&self) -> &SyntaxNode {
3612 &self.syntax
3613 }
3614}
3615impl ast::VisibilityOwner for Module {}
3616impl ast::NameOwner for Module {}
3617impl ast::AttrsOwner for Module {}
3618impl ast::DocCommentsOwner for Module {}
3619impl Module {
3620 pub fn mod_kw(&self) -> Option<ModKw> {
3621 support::token(&self.syntax)
3622 }
3623 pub fn item_list(&self) -> Option<ItemList> {
3624 support::child(&self.syntax)
3625 }
3626 pub fn semi(&self) -> Option<Semi> {
3627 support::token(&self.syntax)
3628 }
3629}
3630#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3631pub struct ItemList {
3632 pub(crate) syntax: SyntaxNode,
3633}
3634impl std::fmt::Display for ItemList {
3635 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3636 std::fmt::Display::fmt(self.syntax(), f)
3637 }
3638}
3639impl AstNode for ItemList {
3640 fn can_cast(kind: SyntaxKind) -> bool {
3641 match kind {
3642 ITEM_LIST => true,
3643 _ => false,
3644 }
3645 }
3646 fn cast(syntax: SyntaxNode) -> Option<Self> {
3647 if Self::can_cast(syntax.kind()) {
3648 Some(Self { syntax })
3649 } else {
3650 None
3651 }
3652 }
3653 fn syntax(&self) -> &SyntaxNode {
3654 &self.syntax
3655 }
3656}
3657impl ast::FnDefOwner for ItemList {}
3658impl ast::ModuleItemOwner for ItemList {}
3659impl ItemList {
3660 pub fn l_curly(&self) -> Option<LCurly> {
3661 support::token(&self.syntax)
3662 }
3663 pub fn impl_items(&self) -> AstChildren<ImplItem> {
3664 support::children(&self.syntax)
3665 }
3666 pub fn r_curly(&self) -> Option<RCurly> {
3667 support::token(&self.syntax)
3668 }
3669}
3670#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3671pub struct ConstDef {
3672 pub(crate) syntax: SyntaxNode,
3673}
3674impl std::fmt::Display for ConstDef {
3675 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3676 std::fmt::Display::fmt(self.syntax(), f)
3677 }
3678}
3679impl AstNode for ConstDef {
3680 fn can_cast(kind: SyntaxKind) -> bool {
3681 match kind {
3682 CONST_DEF => true,
3683 _ => false,
3684 }
3685 }
3686 fn cast(syntax: SyntaxNode) -> Option<Self> {
3687 if Self::can_cast(syntax.kind()) {
3688 Some(Self { syntax })
3689 } else {
3690 None
3691 }
3692 }
3693 fn syntax(&self) -> &SyntaxNode {
3694 &self.syntax
3695 }
3696}
3697impl ast::VisibilityOwner for ConstDef {}
3698impl ast::NameOwner for ConstDef {}
3699impl ast::TypeParamsOwner for ConstDef {}
3700impl ast::AttrsOwner for ConstDef {}
3701impl ast::DocCommentsOwner for ConstDef {}
3702impl ast::TypeAscriptionOwner for ConstDef {}
3703impl ConstDef {
3704 pub fn default_kw(&self) -> Option<DefaultKw> {
3705 support::token(&self.syntax)
3706 }
3707 pub fn const_kw(&self) -> Option<ConstKw> {
3708 support::token(&self.syntax)
3709 }
3710 pub fn eq(&self) -> Option<Eq> {
3711 support::token(&self.syntax)
3712 }
3713 pub fn body(&self) -> Option<Expr> {
3714 support::child(&self.syntax)
3715 }
3716 pub fn semi(&self) -> Option<Semi> {
3717 support::token(&self.syntax)
3718 }
3719}
3720#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3721pub struct StaticDef {
3722 pub(crate) syntax: SyntaxNode,
3723}
3724impl std::fmt::Display for StaticDef {
3725 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3726 std::fmt::Display::fmt(self.syntax(), f)
3727 }
3728}
3729impl AstNode for StaticDef {
3730 fn can_cast(kind: SyntaxKind) -> bool {
3731 match kind {
3732 STATIC_DEF => true,
3733 _ => false,
3734 }
3735 }
3736 fn cast(syntax: SyntaxNode) -> Option<Self> {
3737 if Self::can_cast(syntax.kind()) {
3738 Some(Self { syntax })
3739 } else {
3740 None
3741 }
3742 }
3743 fn syntax(&self) -> &SyntaxNode {
3744 &self.syntax
3745 }
3746}
3747impl ast::VisibilityOwner for StaticDef {}
3748impl ast::NameOwner for StaticDef {}
3749impl ast::TypeParamsOwner for StaticDef {}
3750impl ast::AttrsOwner for StaticDef {}
3751impl ast::DocCommentsOwner for StaticDef {}
3752impl ast::TypeAscriptionOwner for StaticDef {}
3753impl StaticDef {
3754 pub fn static_kw(&self) -> Option<StaticKw> {
3755 support::token(&self.syntax)
3756 }
3757 pub fn mut_kw(&self) -> Option<MutKw> {
3758 support::token(&self.syntax)
3759 }
3760 pub fn eq(&self) -> Option<Eq> {
3761 support::token(&self.syntax)
3762 }
3763 pub fn body(&self) -> Option<Expr> {
3764 support::child(&self.syntax)
3765 }
3766 pub fn semi(&self) -> Option<Semi> {
3767 support::token(&self.syntax)
3768 }
3769}
3770#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3771pub struct TypeAliasDef {
3772 pub(crate) syntax: SyntaxNode,
3773}
3774impl std::fmt::Display for TypeAliasDef {
3775 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3776 std::fmt::Display::fmt(self.syntax(), f)
3777 }
3778}
3779impl AstNode for TypeAliasDef {
3780 fn can_cast(kind: SyntaxKind) -> bool {
3781 match kind {
3782 TYPE_ALIAS_DEF => true,
3783 _ => false,
3784 }
3785 }
3786 fn cast(syntax: SyntaxNode) -> Option<Self> {
3787 if Self::can_cast(syntax.kind()) {
3788 Some(Self { syntax })
3789 } else {
3790 None
3791 }
3792 }
3793 fn syntax(&self) -> &SyntaxNode {
3794 &self.syntax
3795 }
3796}
3797impl ast::VisibilityOwner for TypeAliasDef {}
3798impl ast::NameOwner for TypeAliasDef {}
3799impl ast::TypeParamsOwner for TypeAliasDef {}
3800impl ast::AttrsOwner for TypeAliasDef {}
3801impl ast::DocCommentsOwner for TypeAliasDef {}
3802impl ast::TypeBoundsOwner for TypeAliasDef {}
3803impl TypeAliasDef {
3804 pub fn default_kw(&self) -> Option<DefaultKw> {
3805 support::token(&self.syntax)
3806 }
3807 pub fn type_kw(&self) -> Option<TypeKw> {
3808 support::token(&self.syntax)
3809 }
3810 pub fn eq(&self) -> Option<Eq> {
3811 support::token(&self.syntax)
3812 }
3813 pub fn type_ref(&self) -> Option<TypeRef> {
3814 support::child(&self.syntax)
3815 }
3816 pub fn semi(&self) -> Option<Semi> {
3817 support::token(&self.syntax)
3818 }
3819}
3820#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3821pub struct ImplDef {
3822 pub(crate) syntax: SyntaxNode,
3823}
3824impl std::fmt::Display for ImplDef {
3825 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3826 std::fmt::Display::fmt(self.syntax(), f)
3827 }
3828}
3829impl AstNode for ImplDef {
3830 fn can_cast(kind: SyntaxKind) -> bool {
3831 match kind {
3832 IMPL_DEF => true,
3833 _ => false,
3834 }
3835 }
3836 fn cast(syntax: SyntaxNode) -> Option<Self> {
3837 if Self::can_cast(syntax.kind()) {
3838 Some(Self { syntax })
3839 } else {
3840 None
3841 }
3842 }
3843 fn syntax(&self) -> &SyntaxNode {
3844 &self.syntax
3845 }
3846}
3847impl ast::TypeParamsOwner for ImplDef {}
3848impl ast::AttrsOwner for ImplDef {}
3849impl ImplDef {
3850 pub fn default_kw(&self) -> Option<DefaultKw> {
3851 support::token(&self.syntax)
3852 }
3853 pub fn const_kw(&self) -> Option<ConstKw> {
3854 support::token(&self.syntax)
3855 }
3856 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
3857 support::token(&self.syntax)
3858 }
3859 pub fn impl_kw(&self) -> Option<ImplKw> {
3860 support::token(&self.syntax)
3861 }
3862 pub fn excl(&self) -> Option<Excl> {
3863 support::token(&self.syntax)
3864 }
3865 pub fn for_kw(&self) -> Option<ForKw> {
3866 support::token(&self.syntax)
3867 }
3868 pub fn item_list(&self) -> Option<ItemList> {
3869 support::child(&self.syntax)
3870 }
3871}
3872#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3873pub struct ParenType {
3874 pub(crate) syntax: SyntaxNode,
3875}
3876impl std::fmt::Display for ParenType {
3877 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3878 std::fmt::Display::fmt(self.syntax(), f)
3879 }
3880}
3881impl AstNode for ParenType {
3882 fn can_cast(kind: SyntaxKind) -> bool {
3883 match kind {
3884 PAREN_TYPE => true,
3885 _ => false,
3886 }
3887 }
3888 fn cast(syntax: SyntaxNode) -> Option<Self> {
3889 if Self::can_cast(syntax.kind()) {
3890 Some(Self { syntax })
3891 } else {
3892 None
3893 }
3894 }
3895 fn syntax(&self) -> &SyntaxNode {
3896 &self.syntax
3897 }
3898}
3899impl ParenType {
3900 pub fn l_paren(&self) -> Option<LParen> {
3901 support::token(&self.syntax)
3902 }
3903 pub fn type_ref(&self) -> Option<TypeRef> {
3904 support::child(&self.syntax)
3905 }
3906 pub fn r_paren(&self) -> Option<RParen> {
3907 support::token(&self.syntax)
3908 }
3909}
3910#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3911pub struct TupleType {
3912 pub(crate) syntax: SyntaxNode,
3913}
3914impl std::fmt::Display for TupleType {
3915 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3916 std::fmt::Display::fmt(self.syntax(), f)
3917 }
3918}
3919impl AstNode for TupleType {
3920 fn can_cast(kind: SyntaxKind) -> bool {
3921 match kind {
3922 TUPLE_TYPE => true,
3923 _ => false,
3924 }
3925 }
3926 fn cast(syntax: SyntaxNode) -> Option<Self> {
3927 if Self::can_cast(syntax.kind()) {
3928 Some(Self { syntax })
3929 } else {
3930 None
3931 }
3932 }
3933 fn syntax(&self) -> &SyntaxNode {
3934 &self.syntax
3935 }
3936}
3937impl TupleType {
3938 pub fn l_paren(&self) -> Option<LParen> {
3939 support::token(&self.syntax)
3940 }
3941 pub fn fields(&self) -> AstChildren<TypeRef> {
3942 support::children(&self.syntax)
3943 }
3944 pub fn r_paren(&self) -> Option<RParen> {
3945 support::token(&self.syntax)
3946 }
3947}
3948#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3949pub struct NeverType {
3950 pub(crate) syntax: SyntaxNode,
3951}
3952impl std::fmt::Display for NeverType {
3953 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3954 std::fmt::Display::fmt(self.syntax(), f)
3955 }
3956}
3957impl AstNode for NeverType {
3958 fn can_cast(kind: SyntaxKind) -> bool {
3959 match kind {
3960 NEVER_TYPE => true,
3961 _ => false,
3962 }
3963 }
3964 fn cast(syntax: SyntaxNode) -> Option<Self> {
3965 if Self::can_cast(syntax.kind()) {
3966 Some(Self { syntax })
3967 } else {
3968 None
3969 }
3970 }
3971 fn syntax(&self) -> &SyntaxNode {
3972 &self.syntax
3973 }
3974}
3975impl NeverType {
3976 pub fn excl(&self) -> Option<Excl> {
3977 support::token(&self.syntax)
3978 }
3979}
3980#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3981pub struct PathType {
3982 pub(crate) syntax: SyntaxNode,
3983}
3984impl std::fmt::Display for PathType {
3985 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3986 std::fmt::Display::fmt(self.syntax(), f)
3987 }
3988}
3989impl AstNode for PathType {
3990 fn can_cast(kind: SyntaxKind) -> bool {
3991 match kind {
3992 PATH_TYPE => true,
3993 _ => false,
3994 }
3995 }
3996 fn cast(syntax: SyntaxNode) -> Option<Self> {
3997 if Self::can_cast(syntax.kind()) {
3998 Some(Self { syntax })
3999 } else {
4000 None
4001 }
4002 }
4003 fn syntax(&self) -> &SyntaxNode {
4004 &self.syntax
4005 }
4006}
4007impl PathType {
4008 pub fn path(&self) -> Option<Path> {
4009 support::child(&self.syntax)
4010 }
4011}
4012#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4013pub struct PointerType {
4014 pub(crate) syntax: SyntaxNode,
4015}
4016impl std::fmt::Display for PointerType {
4017 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4018 std::fmt::Display::fmt(self.syntax(), f)
4019 }
4020}
4021impl AstNode for PointerType {
4022 fn can_cast(kind: SyntaxKind) -> bool {
4023 match kind {
4024 POINTER_TYPE => true,
4025 _ => false,
4026 }
4027 }
4028 fn cast(syntax: SyntaxNode) -> Option<Self> {
4029 if Self::can_cast(syntax.kind()) {
4030 Some(Self { syntax })
4031 } else {
4032 None
4033 }
4034 }
4035 fn syntax(&self) -> &SyntaxNode {
4036 &self.syntax
4037 }
4038}
4039impl PointerType {
4040 pub fn star(&self) -> Option<Star> {
4041 support::token(&self.syntax)
4042 }
4043 pub fn const_kw(&self) -> Option<ConstKw> {
4044 support::token(&self.syntax)
4045 }
4046 pub fn type_ref(&self) -> Option<TypeRef> {
4047 support::child(&self.syntax)
4048 }
4049}
4050#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4051pub struct ArrayType {
4052 pub(crate) syntax: SyntaxNode,
4053}
4054impl std::fmt::Display for ArrayType {
4055 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4056 std::fmt::Display::fmt(self.syntax(), f)
4057 }
4058}
4059impl AstNode for ArrayType {
4060 fn can_cast(kind: SyntaxKind) -> bool {
4061 match kind {
4062 ARRAY_TYPE => true,
4063 _ => false,
4064 }
4065 }
4066 fn cast(syntax: SyntaxNode) -> Option<Self> {
4067 if Self::can_cast(syntax.kind()) {
4068 Some(Self { syntax })
4069 } else {
4070 None
4071 }
4072 }
4073 fn syntax(&self) -> &SyntaxNode {
4074 &self.syntax
4075 }
4076}
4077impl ArrayType {
4078 pub fn l_brack(&self) -> Option<LBrack> {
4079 support::token(&self.syntax)
4080 }
4081 pub fn type_ref(&self) -> Option<TypeRef> {
4082 support::child(&self.syntax)
4083 }
4084 pub fn semi(&self) -> Option<Semi> {
4085 support::token(&self.syntax)
4086 }
4087 pub fn expr(&self) -> Option<Expr> {
4088 support::child(&self.syntax)
4089 }
4090 pub fn r_brack(&self) -> Option<RBrack> {
4091 support::token(&self.syntax)
4092 }
4093}
4094#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4095pub struct SliceType {
4096 pub(crate) syntax: SyntaxNode,
4097}
4098impl std::fmt::Display for SliceType {
4099 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4100 std::fmt::Display::fmt(self.syntax(), f)
4101 }
4102}
4103impl AstNode for SliceType {
4104 fn can_cast(kind: SyntaxKind) -> bool {
4105 match kind {
4106 SLICE_TYPE => true,
4107 _ => false,
4108 }
4109 }
4110 fn cast(syntax: SyntaxNode) -> Option<Self> {
4111 if Self::can_cast(syntax.kind()) {
4112 Some(Self { syntax })
4113 } else {
4114 None
4115 }
4116 }
4117 fn syntax(&self) -> &SyntaxNode {
4118 &self.syntax
4119 }
4120}
4121impl SliceType {
4122 pub fn l_brack(&self) -> Option<LBrack> {
4123 support::token(&self.syntax)
4124 }
4125 pub fn type_ref(&self) -> Option<TypeRef> {
4126 support::child(&self.syntax)
4127 }
4128 pub fn r_brack(&self) -> Option<RBrack> {
4129 support::token(&self.syntax)
4130 }
4131}
4132#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4133pub struct ReferenceType {
4134 pub(crate) syntax: SyntaxNode,
4135}
4136impl std::fmt::Display for ReferenceType {
4137 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4138 std::fmt::Display::fmt(self.syntax(), f)
4139 }
4140}
4141impl AstNode for ReferenceType {
4142 fn can_cast(kind: SyntaxKind) -> bool {
4143 match kind {
4144 REFERENCE_TYPE => true,
4145 _ => false,
4146 }
4147 }
4148 fn cast(syntax: SyntaxNode) -> Option<Self> {
4149 if Self::can_cast(syntax.kind()) {
4150 Some(Self { syntax })
4151 } else {
4152 None
4153 }
4154 }
4155 fn syntax(&self) -> &SyntaxNode {
4156 &self.syntax
4157 }
4158}
4159impl ReferenceType {
4160 pub fn amp(&self) -> Option<Amp> {
4161 support::token(&self.syntax)
4162 }
4163 pub fn lifetime(&self) -> Option<Lifetime> {
4164 support::token(&self.syntax)
4165 }
4166 pub fn mut_kw(&self) -> Option<MutKw> {
4167 support::token(&self.syntax)
4168 }
4169 pub fn type_ref(&self) -> Option<TypeRef> {
4170 support::child(&self.syntax)
4171 }
4172}
4173#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4174pub struct PlaceholderType {
4175 pub(crate) syntax: SyntaxNode,
4176}
4177impl std::fmt::Display for PlaceholderType {
4178 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4179 std::fmt::Display::fmt(self.syntax(), f)
4180 }
4181}
4182impl AstNode for PlaceholderType {
4183 fn can_cast(kind: SyntaxKind) -> bool {
4184 match kind {
4185 PLACEHOLDER_TYPE => true,
4186 _ => false,
4187 }
4188 }
4189 fn cast(syntax: SyntaxNode) -> Option<Self> {
4190 if Self::can_cast(syntax.kind()) {
4191 Some(Self { syntax })
4192 } else {
4193 None
4194 }
4195 }
4196 fn syntax(&self) -> &SyntaxNode {
4197 &self.syntax
4198 }
4199}
4200impl PlaceholderType {
4201 pub fn underscore(&self) -> Option<Underscore> {
4202 support::token(&self.syntax)
4203 }
4204}
4205#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4206pub struct FnPointerType {
4207 pub(crate) syntax: SyntaxNode,
4208}
4209impl std::fmt::Display for FnPointerType {
4210 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4211 std::fmt::Display::fmt(self.syntax(), f)
4212 }
4213}
4214impl AstNode for FnPointerType {
4215 fn can_cast(kind: SyntaxKind) -> bool {
4216 match kind {
4217 FN_POINTER_TYPE => true,
4218 _ => false,
4219 }
4220 }
4221 fn cast(syntax: SyntaxNode) -> Option<Self> {
4222 if Self::can_cast(syntax.kind()) {
4223 Some(Self { syntax })
4224 } else {
4225 None
4226 }
4227 }
4228 fn syntax(&self) -> &SyntaxNode {
4229 &self.syntax
4230 }
4231}
4232impl FnPointerType {
4233 pub fn abi(&self) -> Option<Abi> {
4234 support::child(&self.syntax)
4235 }
4236 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
4237 support::token(&self.syntax)
4238 }
4239 pub fn fn_kw(&self) -> Option<FnKw> {
4240 support::token(&self.syntax)
4241 }
4242 pub fn param_list(&self) -> Option<ParamList> {
4243 support::child(&self.syntax)
4244 }
4245 pub fn ret_type(&self) -> Option<RetType> {
4246 support::child(&self.syntax)
4247 }
4248}
4249#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4250pub struct ForType {
4251 pub(crate) syntax: SyntaxNode,
4252}
4253impl std::fmt::Display for ForType {
4254 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4255 std::fmt::Display::fmt(self.syntax(), f)
4256 }
4257}
4258impl AstNode for ForType {
4259 fn can_cast(kind: SyntaxKind) -> bool {
4260 match kind {
4261 FOR_TYPE => true,
4262 _ => false,
4263 }
4264 }
4265 fn cast(syntax: SyntaxNode) -> Option<Self> {
4266 if Self::can_cast(syntax.kind()) {
4267 Some(Self { syntax })
4268 } else {
4269 None
4270 }
4271 }
4272 fn syntax(&self) -> &SyntaxNode {
4273 &self.syntax
4274 }
4275}
4276impl ForType {
4277 pub fn for_kw(&self) -> Option<ForKw> {
4278 support::token(&self.syntax)
4279 }
4280 pub fn type_param_list(&self) -> Option<TypeParamList> {
4281 support::child(&self.syntax)
4282 }
4283 pub fn type_ref(&self) -> Option<TypeRef> {
4284 support::child(&self.syntax)
4285 }
4286}
4287#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4288pub struct ImplTraitType {
4289 pub(crate) syntax: SyntaxNode,
4290}
4291impl std::fmt::Display for ImplTraitType {
4292 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4293 std::fmt::Display::fmt(self.syntax(), f)
4294 }
4295}
4296impl AstNode for ImplTraitType {
4297 fn can_cast(kind: SyntaxKind) -> bool {
4298 match kind {
4299 IMPL_TRAIT_TYPE => true,
4300 _ => false,
4301 }
4302 }
4303 fn cast(syntax: SyntaxNode) -> Option<Self> {
4304 if Self::can_cast(syntax.kind()) {
4305 Some(Self { syntax })
4306 } else {
4307 None
4308 }
4309 }
4310 fn syntax(&self) -> &SyntaxNode {
4311 &self.syntax
4312 }
4313}
4314impl ast::TypeBoundsOwner for ImplTraitType {}
4315impl ImplTraitType {
4316 pub fn impl_kw(&self) -> Option<ImplKw> {
4317 support::token(&self.syntax)
4318 }
4319}
4320#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4321pub struct DynTraitType {
4322 pub(crate) syntax: SyntaxNode,
4323}
4324impl std::fmt::Display for DynTraitType {
4325 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4326 std::fmt::Display::fmt(self.syntax(), f)
4327 }
4328}
4329impl AstNode for DynTraitType {
4330 fn can_cast(kind: SyntaxKind) -> bool {
4331 match kind {
4332 DYN_TRAIT_TYPE => true,
4333 _ => false,
4334 }
4335 }
4336 fn cast(syntax: SyntaxNode) -> Option<Self> {
4337 if Self::can_cast(syntax.kind()) {
4338 Some(Self { syntax })
4339 } else {
4340 None
4341 }
4342 }
4343 fn syntax(&self) -> &SyntaxNode {
4344 &self.syntax
4345 }
4346}
4347impl ast::TypeBoundsOwner for DynTraitType {}
4348impl DynTraitType {
4349 pub fn dyn_kw(&self) -> Option<DynKw> {
4350 support::token(&self.syntax)
4351 }
4352}
4353#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4354pub struct TupleExpr {
4355 pub(crate) syntax: SyntaxNode,
4356}
4357impl std::fmt::Display for TupleExpr {
4358 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4359 std::fmt::Display::fmt(self.syntax(), f)
4360 }
4361}
4362impl AstNode for TupleExpr {
4363 fn can_cast(kind: SyntaxKind) -> bool {
4364 match kind {
4365 TUPLE_EXPR => true,
4366 _ => false,
4367 }
4368 }
4369 fn cast(syntax: SyntaxNode) -> Option<Self> {
4370 if Self::can_cast(syntax.kind()) {
4371 Some(Self { syntax })
4372 } else {
4373 None
4374 }
4375 }
4376 fn syntax(&self) -> &SyntaxNode {
4377 &self.syntax
4378 }
4379}
4380impl ast::AttrsOwner for TupleExpr {}
4381impl TupleExpr {
4382 pub fn l_paren(&self) -> Option<LParen> {
4383 support::token(&self.syntax)
4384 }
4385 pub fn exprs(&self) -> AstChildren<Expr> {
4386 support::children(&self.syntax)
4387 }
4388 pub fn r_paren(&self) -> Option<RParen> {
4389 support::token(&self.syntax)
4390 }
4391}
4392#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4393pub struct ArrayExpr {
4394 pub(crate) syntax: SyntaxNode,
4395}
4396impl std::fmt::Display for ArrayExpr {
4397 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4398 std::fmt::Display::fmt(self.syntax(), f)
4399 }
4400}
4401impl AstNode for ArrayExpr {
4402 fn can_cast(kind: SyntaxKind) -> bool {
4403 match kind {
4404 ARRAY_EXPR => true,
4405 _ => false,
4406 }
4407 }
4408 fn cast(syntax: SyntaxNode) -> Option<Self> {
4409 if Self::can_cast(syntax.kind()) {
4410 Some(Self { syntax })
4411 } else {
4412 None
4413 }
4414 }
4415 fn syntax(&self) -> &SyntaxNode {
4416 &self.syntax
4417 }
4418}
4419impl ast::AttrsOwner for ArrayExpr {}
4420impl ArrayExpr {
4421 pub fn l_brack(&self) -> Option<LBrack> {
4422 support::token(&self.syntax)
4423 }
4424 pub fn exprs(&self) -> AstChildren<Expr> {
4425 support::children(&self.syntax)
4426 }
4427 pub fn semi(&self) -> Option<Semi> {
4428 support::token(&self.syntax)
4429 }
4430 pub fn r_brack(&self) -> Option<RBrack> {
4431 support::token(&self.syntax)
4432 }
4433}
4434#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4435pub struct ParenExpr {
4436 pub(crate) syntax: SyntaxNode,
4437}
4438impl std::fmt::Display for ParenExpr {
4439 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4440 std::fmt::Display::fmt(self.syntax(), f)
4441 }
4442}
4443impl AstNode for ParenExpr {
4444 fn can_cast(kind: SyntaxKind) -> bool {
4445 match kind {
4446 PAREN_EXPR => true,
4447 _ => false,
4448 }
4449 }
4450 fn cast(syntax: SyntaxNode) -> Option<Self> {
4451 if Self::can_cast(syntax.kind()) {
4452 Some(Self { syntax })
4453 } else {
4454 None
4455 }
4456 }
4457 fn syntax(&self) -> &SyntaxNode {
4458 &self.syntax
4459 }
4460}
4461impl ast::AttrsOwner for ParenExpr {}
4462impl ParenExpr {
4463 pub fn l_paren(&self) -> Option<LParen> {
4464 support::token(&self.syntax)
4465 }
4466 pub fn expr(&self) -> Option<Expr> {
4467 support::child(&self.syntax)
4468 }
4469 pub fn r_paren(&self) -> Option<RParen> {
4470 support::token(&self.syntax)
4471 }
4472}
4473#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4474pub struct PathExpr {
4475 pub(crate) syntax: SyntaxNode,
4476}
4477impl std::fmt::Display for PathExpr {
4478 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4479 std::fmt::Display::fmt(self.syntax(), f)
4480 }
4481}
4482impl AstNode for PathExpr {
4483 fn can_cast(kind: SyntaxKind) -> bool {
4484 match kind {
4485 PATH_EXPR => true,
4486 _ => false,
4487 }
4488 }
4489 fn cast(syntax: SyntaxNode) -> Option<Self> {
4490 if Self::can_cast(syntax.kind()) {
4491 Some(Self { syntax })
4492 } else {
4493 None
4494 }
4495 }
4496 fn syntax(&self) -> &SyntaxNode {
4497 &self.syntax
4498 }
4499}
4500impl PathExpr {
4501 pub fn path(&self) -> Option<Path> {
4502 support::child(&self.syntax)
4503 }
4504}
4505#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4506pub struct LambdaExpr {
4507 pub(crate) syntax: SyntaxNode,
4508}
4509impl std::fmt::Display for LambdaExpr {
4510 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4511 std::fmt::Display::fmt(self.syntax(), f)
4512 }
4513}
4514impl AstNode for LambdaExpr {
4515 fn can_cast(kind: SyntaxKind) -> bool {
4516 match kind {
4517 LAMBDA_EXPR => true,
4518 _ => false,
4519 }
4520 }
4521 fn cast(syntax: SyntaxNode) -> Option<Self> {
4522 if Self::can_cast(syntax.kind()) {
4523 Some(Self { syntax })
4524 } else {
4525 None
4526 }
4527 }
4528 fn syntax(&self) -> &SyntaxNode {
4529 &self.syntax
4530 }
4531}
4532impl ast::AttrsOwner for LambdaExpr {}
4533impl LambdaExpr {
4534 pub fn static_kw(&self) -> Option<StaticKw> {
4535 support::token(&self.syntax)
4536 }
4537 pub fn async_kw(&self) -> Option<AsyncKw> {
4538 support::token(&self.syntax)
4539 }
4540 pub fn move_kw(&self) -> Option<MoveKw> {
4541 support::token(&self.syntax)
4542 }
4543 pub fn param_list(&self) -> Option<ParamList> {
4544 support::child(&self.syntax)
4545 }
4546 pub fn ret_type(&self) -> Option<RetType> {
4547 support::child(&self.syntax)
4548 }
4549 pub fn body(&self) -> Option<Expr> {
4550 support::child(&self.syntax)
4551 }
4552}
4553#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4554pub struct IfExpr {
4555 pub(crate) syntax: SyntaxNode,
4556}
4557impl std::fmt::Display for IfExpr {
4558 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4559 std::fmt::Display::fmt(self.syntax(), f)
4560 }
4561}
4562impl AstNode for IfExpr {
4563 fn can_cast(kind: SyntaxKind) -> bool {
4564 match kind {
4565 IF_EXPR => true,
4566 _ => false,
4567 }
4568 }
4569 fn cast(syntax: SyntaxNode) -> Option<Self> {
4570 if Self::can_cast(syntax.kind()) {
4571 Some(Self { syntax })
4572 } else {
4573 None
4574 }
4575 }
4576 fn syntax(&self) -> &SyntaxNode {
4577 &self.syntax
4578 }
4579}
4580impl ast::AttrsOwner for IfExpr {}
4581impl IfExpr {
4582 pub fn if_kw(&self) -> Option<IfKw> {
4583 support::token(&self.syntax)
4584 }
4585 pub fn condition(&self) -> Option<Condition> {
4586 support::child(&self.syntax)
4587 }
4588}
4589#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4590pub struct LoopExpr {
4591 pub(crate) syntax: SyntaxNode,
4592}
4593impl std::fmt::Display for LoopExpr {
4594 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4595 std::fmt::Display::fmt(self.syntax(), f)
4596 }
4597}
4598impl AstNode for LoopExpr {
4599 fn can_cast(kind: SyntaxKind) -> bool {
4600 match kind {
4601 LOOP_EXPR => true,
4602 _ => false,
4603 }
4604 }
4605 fn cast(syntax: SyntaxNode) -> Option<Self> {
4606 if Self::can_cast(syntax.kind()) {
4607 Some(Self { syntax })
4608 } else {
4609 None
4610 }
4611 }
4612 fn syntax(&self) -> &SyntaxNode {
4613 &self.syntax
4614 }
4615}
4616impl ast::AttrsOwner for LoopExpr {}
4617impl ast::LoopBodyOwner for LoopExpr {}
4618impl LoopExpr {
4619 pub fn loop_kw(&self) -> Option<LoopKw> {
4620 support::token(&self.syntax)
4621 }
4622}
4623#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4624pub struct TryBlockExpr {
4625 pub(crate) syntax: SyntaxNode,
4626}
4627impl std::fmt::Display for TryBlockExpr {
4628 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4629 std::fmt::Display::fmt(self.syntax(), f)
4630 }
4631}
4632impl AstNode for TryBlockExpr {
4633 fn can_cast(kind: SyntaxKind) -> bool {
4634 match kind {
4635 TRY_BLOCK_EXPR => true,
4636 _ => false,
4637 }
4638 }
4639 fn cast(syntax: SyntaxNode) -> Option<Self> {
4640 if Self::can_cast(syntax.kind()) {
4641 Some(Self { syntax })
4642 } else {
4643 None
4644 }
4645 }
4646 fn syntax(&self) -> &SyntaxNode {
4647 &self.syntax
4648 }
4649}
4650impl ast::AttrsOwner for TryBlockExpr {}
4651impl TryBlockExpr {
4652 pub fn try_kw(&self) -> Option<TryKw> {
4653 support::token(&self.syntax)
4654 }
4655 pub fn body(&self) -> Option<BlockExpr> {
4656 support::child(&self.syntax)
4657 }
4658}
4659#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4660pub struct ForExpr {
4661 pub(crate) syntax: SyntaxNode,
4662}
4663impl std::fmt::Display for ForExpr {
4664 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4665 std::fmt::Display::fmt(self.syntax(), f)
4666 }
4667}
4668impl AstNode for ForExpr {
4669 fn can_cast(kind: SyntaxKind) -> bool {
4670 match kind {
4671 FOR_EXPR => true,
4672 _ => false,
4673 }
4674 }
4675 fn cast(syntax: SyntaxNode) -> Option<Self> {
4676 if Self::can_cast(syntax.kind()) {
4677 Some(Self { syntax })
4678 } else {
4679 None
4680 }
4681 }
4682 fn syntax(&self) -> &SyntaxNode {
4683 &self.syntax
4684 }
4685}
4686impl ast::AttrsOwner for ForExpr {}
4687impl ast::LoopBodyOwner for ForExpr {}
4688impl ForExpr {
4689 pub fn for_kw(&self) -> Option<ForKw> {
4690 support::token(&self.syntax)
4691 }
4692 pub fn pat(&self) -> Option<Pat> {
4693 support::child(&self.syntax)
4694 }
4695 pub fn in_kw(&self) -> Option<InKw> {
4696 support::token(&self.syntax)
4697 }
4698 pub fn iterable(&self) -> Option<Expr> {
4699 support::child(&self.syntax)
4700 }
4701}
4702#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4703pub struct WhileExpr {
4704 pub(crate) syntax: SyntaxNode,
4705}
4706impl std::fmt::Display for WhileExpr {
4707 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4708 std::fmt::Display::fmt(self.syntax(), f)
4709 }
4710}
4711impl AstNode for WhileExpr {
4712 fn can_cast(kind: SyntaxKind) -> bool {
4713 match kind {
4714 WHILE_EXPR => true,
4715 _ => false,
4716 }
4717 }
4718 fn cast(syntax: SyntaxNode) -> Option<Self> {
4719 if Self::can_cast(syntax.kind()) {
4720 Some(Self { syntax })
4721 } else {
4722 None
4723 }
4724 }
4725 fn syntax(&self) -> &SyntaxNode {
4726 &self.syntax
4727 }
4728}
4729impl ast::AttrsOwner for WhileExpr {}
4730impl ast::LoopBodyOwner for WhileExpr {}
4731impl WhileExpr {
4732 pub fn while_kw(&self) -> Option<WhileKw> {
4733 support::token(&self.syntax)
4734 }
4735 pub fn condition(&self) -> Option<Condition> {
4736 support::child(&self.syntax)
4737 }
4738}
4739#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4740pub struct ContinueExpr {
4741 pub(crate) syntax: SyntaxNode,
4742}
4743impl std::fmt::Display for ContinueExpr {
4744 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4745 std::fmt::Display::fmt(self.syntax(), f)
4746 }
4747}
4748impl AstNode for ContinueExpr {
4749 fn can_cast(kind: SyntaxKind) -> bool {
4750 match kind {
4751 CONTINUE_EXPR => true,
4752 _ => false,
4753 }
4754 }
4755 fn cast(syntax: SyntaxNode) -> Option<Self> {
4756 if Self::can_cast(syntax.kind()) {
4757 Some(Self { syntax })
4758 } else {
4759 None
4760 }
4761 }
4762 fn syntax(&self) -> &SyntaxNode {
4763 &self.syntax
4764 }
4765}
4766impl ast::AttrsOwner for ContinueExpr {}
4767impl ContinueExpr {
4768 pub fn continue_kw(&self) -> Option<ContinueKw> {
4769 support::token(&self.syntax)
4770 }
4771 pub fn lifetime(&self) -> Option<Lifetime> {
4772 support::token(&self.syntax)
4773 }
4774}
4775#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4776pub struct BreakExpr {
4777 pub(crate) syntax: SyntaxNode,
4778}
4779impl std::fmt::Display for BreakExpr {
4780 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4781 std::fmt::Display::fmt(self.syntax(), f)
4782 }
4783}
4784impl AstNode for BreakExpr {
4785 fn can_cast(kind: SyntaxKind) -> bool {
4786 match kind {
4787 BREAK_EXPR => true,
4788 _ => false,
4789 }
4790 }
4791 fn cast(syntax: SyntaxNode) -> Option<Self> {
4792 if Self::can_cast(syntax.kind()) {
4793 Some(Self { syntax })
4794 } else {
4795 None
4796 }
4797 }
4798 fn syntax(&self) -> &SyntaxNode {
4799 &self.syntax
4800 }
4801}
4802impl ast::AttrsOwner for BreakExpr {}
4803impl BreakExpr {
4804 pub fn break_kw(&self) -> Option<BreakKw> {
4805 support::token(&self.syntax)
4806 }
4807 pub fn lifetime(&self) -> Option<Lifetime> {
4808 support::token(&self.syntax)
4809 }
4810 pub fn expr(&self) -> Option<Expr> {
4811 support::child(&self.syntax)
4812 }
4813}
4814#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4815pub struct Label {
4816 pub(crate) syntax: SyntaxNode,
4817}
4818impl std::fmt::Display for Label {
4819 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4820 std::fmt::Display::fmt(self.syntax(), f)
4821 }
4822}
4823impl AstNode for Label {
4824 fn can_cast(kind: SyntaxKind) -> bool {
4825 match kind {
4826 LABEL => true,
4827 _ => false,
4828 }
4829 }
4830 fn cast(syntax: SyntaxNode) -> Option<Self> {
4831 if Self::can_cast(syntax.kind()) {
4832 Some(Self { syntax })
4833 } else {
4834 None
4835 }
4836 }
4837 fn syntax(&self) -> &SyntaxNode {
4838 &self.syntax
4839 }
4840}
4841impl Label {
4842 pub fn lifetime(&self) -> Option<Lifetime> {
4843 support::token(&self.syntax)
4844 }
4845}
4846#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4847pub struct BlockExpr {
4848 pub(crate) syntax: SyntaxNode,
4849}
4850impl std::fmt::Display for BlockExpr {
4851 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4852 std::fmt::Display::fmt(self.syntax(), f)
4853 }
4854}
4855impl AstNode for BlockExpr {
4856 fn can_cast(kind: SyntaxKind) -> bool {
4857 match kind {
4858 BLOCK_EXPR => true,
4859 _ => false,
4860 }
4861 }
4862 fn cast(syntax: SyntaxNode) -> Option<Self> {
4863 if Self::can_cast(syntax.kind()) {
4864 Some(Self { syntax })
4865 } else {
4866 None
4867 }
4868 }
4869 fn syntax(&self) -> &SyntaxNode {
4870 &self.syntax
4871 }
4872}
4873impl ast::AttrsOwner for BlockExpr {}
4874impl BlockExpr {
4875 pub fn label(&self) -> Option<Label> {
4876 support::child(&self.syntax)
4877 }
4878 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
4879 support::token(&self.syntax)
4880 }
4881 pub fn block(&self) -> Option<Block> {
4882 support::child(&self.syntax)
4883 }
4884}
4885#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4886pub struct ReturnExpr {
4887 pub(crate) syntax: SyntaxNode,
4888}
4889impl std::fmt::Display for ReturnExpr {
4890 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4891 std::fmt::Display::fmt(self.syntax(), f)
4892 }
4893}
4894impl AstNode for ReturnExpr {
4895 fn can_cast(kind: SyntaxKind) -> bool {
4896 match kind {
4897 RETURN_EXPR => true,
4898 _ => false,
4899 }
4900 }
4901 fn cast(syntax: SyntaxNode) -> Option<Self> {
4902 if Self::can_cast(syntax.kind()) {
4903 Some(Self { syntax })
4904 } else {
4905 None
4906 }
4907 }
4908 fn syntax(&self) -> &SyntaxNode {
4909 &self.syntax
4910 }
4911}
4912impl ast::AttrsOwner for ReturnExpr {}
4913impl ReturnExpr {
4914 pub fn expr(&self) -> Option<Expr> {
4915 support::child(&self.syntax)
4916 }
4917}
4918#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4919pub struct CallExpr {
4920 pub(crate) syntax: SyntaxNode,
4921}
4922impl std::fmt::Display for CallExpr {
4923 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4924 std::fmt::Display::fmt(self.syntax(), f)
4925 }
4926}
4927impl AstNode for CallExpr {
4928 fn can_cast(kind: SyntaxKind) -> bool {
4929 match kind {
4930 CALL_EXPR => true,
4931 _ => false,
4932 }
4933 }
4934 fn cast(syntax: SyntaxNode) -> Option<Self> {
4935 if Self::can_cast(syntax.kind()) {
4936 Some(Self { syntax })
4937 } else {
4938 None
4939 }
4940 }
4941 fn syntax(&self) -> &SyntaxNode {
4942 &self.syntax
4943 }
4944}
4945impl ast::ArgListOwner for CallExpr {}
4946impl CallExpr {
4947 pub fn expr(&self) -> Option<Expr> {
4948 support::child(&self.syntax)
4949 }
4950}
4951#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4952pub struct MethodCallExpr {
4953 pub(crate) syntax: SyntaxNode,
4954}
4955impl std::fmt::Display for MethodCallExpr {
4956 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4957 std::fmt::Display::fmt(self.syntax(), f)
4958 }
4959}
4960impl AstNode for MethodCallExpr {
4961 fn can_cast(kind: SyntaxKind) -> bool {
4962 match kind {
4963 METHOD_CALL_EXPR => true,
4964 _ => false,
4965 }
4966 }
4967 fn cast(syntax: SyntaxNode) -> Option<Self> {
4968 if Self::can_cast(syntax.kind()) {
4969 Some(Self { syntax })
4970 } else {
4971 None
4972 }
4973 }
4974 fn syntax(&self) -> &SyntaxNode {
4975 &self.syntax
4976 }
4977}
4978impl ast::AttrsOwner for MethodCallExpr {}
4979impl ast::ArgListOwner for MethodCallExpr {}
4980impl MethodCallExpr {
4981 pub fn expr(&self) -> Option<Expr> {
4982 support::child(&self.syntax)
4983 }
4984 pub fn dot(&self) -> Option<Dot> {
4985 support::token(&self.syntax)
4986 }
4987 pub fn name_ref(&self) -> Option<NameRef> {
4988 support::child(&self.syntax)
4989 }
4990 pub fn type_arg_list(&self) -> Option<TypeArgList> {
4991 support::child(&self.syntax)
4992 }
4993}
4994#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4995pub struct IndexExpr {
4996 pub(crate) syntax: SyntaxNode,
4997}
4998impl std::fmt::Display for IndexExpr {
4999 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5000 std::fmt::Display::fmt(self.syntax(), f)
5001 }
5002}
5003impl AstNode for IndexExpr {
5004 fn can_cast(kind: SyntaxKind) -> bool {
5005 match kind {
5006 INDEX_EXPR => true,
5007 _ => false,
5008 }
5009 }
5010 fn cast(syntax: SyntaxNode) -> Option<Self> {
5011 if Self::can_cast(syntax.kind()) {
5012 Some(Self { syntax })
5013 } else {
5014 None
5015 }
5016 }
5017 fn syntax(&self) -> &SyntaxNode {
5018 &self.syntax
5019 }
5020}
5021impl ast::AttrsOwner for IndexExpr {}
5022impl IndexExpr {
5023 pub fn l_brack(&self) -> Option<LBrack> {
5024 support::token(&self.syntax)
5025 }
5026 pub fn r_brack(&self) -> Option<RBrack> {
5027 support::token(&self.syntax)
5028 }
5029}
5030#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5031pub struct FieldExpr {
5032 pub(crate) syntax: SyntaxNode,
5033}
5034impl std::fmt::Display for FieldExpr {
5035 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5036 std::fmt::Display::fmt(self.syntax(), f)
5037 }
5038}
5039impl AstNode for FieldExpr {
5040 fn can_cast(kind: SyntaxKind) -> bool {
5041 match kind {
5042 FIELD_EXPR => true,
5043 _ => false,
5044 }
5045 }
5046 fn cast(syntax: SyntaxNode) -> Option<Self> {
5047 if Self::can_cast(syntax.kind()) {
5048 Some(Self { syntax })
5049 } else {
5050 None
5051 }
5052 }
5053 fn syntax(&self) -> &SyntaxNode {
5054 &self.syntax
5055 }
5056}
5057impl ast::AttrsOwner for FieldExpr {}
5058impl FieldExpr {
5059 pub fn expr(&self) -> Option<Expr> {
5060 support::child(&self.syntax)
5061 }
5062 pub fn dot(&self) -> Option<Dot> {
5063 support::token(&self.syntax)
5064 }
5065 pub fn name_ref(&self) -> Option<NameRef> {
5066 support::child(&self.syntax)
5067 }
5068}
5069#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5070pub struct AwaitExpr {
5071 pub(crate) syntax: SyntaxNode,
5072}
5073impl std::fmt::Display for AwaitExpr {
5074 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5075 std::fmt::Display::fmt(self.syntax(), f)
5076 }
5077}
5078impl AstNode for AwaitExpr {
5079 fn can_cast(kind: SyntaxKind) -> bool {
5080 match kind {
5081 AWAIT_EXPR => true,
5082 _ => false,
5083 }
5084 }
5085 fn cast(syntax: SyntaxNode) -> Option<Self> {
5086 if Self::can_cast(syntax.kind()) {
5087 Some(Self { syntax })
5088 } else {
5089 None
5090 }
5091 }
5092 fn syntax(&self) -> &SyntaxNode {
5093 &self.syntax
5094 }
5095}
5096impl ast::AttrsOwner for AwaitExpr {}
5097impl AwaitExpr {
5098 pub fn expr(&self) -> Option<Expr> {
5099 support::child(&self.syntax)
5100 }
5101 pub fn dot(&self) -> Option<Dot> {
5102 support::token(&self.syntax)
5103 }
5104 pub fn await_kw(&self) -> Option<AwaitKw> {
5105 support::token(&self.syntax)
5106 }
5107}
5108#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5109pub struct TryExpr {
5110 pub(crate) syntax: SyntaxNode,
5111}
5112impl std::fmt::Display for TryExpr {
5113 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5114 std::fmt::Display::fmt(self.syntax(), f)
5115 }
5116}
5117impl AstNode for TryExpr {
5118 fn can_cast(kind: SyntaxKind) -> bool {
5119 match kind {
5120 TRY_EXPR => true,
5121 _ => false,
5122 }
5123 }
5124 fn cast(syntax: SyntaxNode) -> Option<Self> {
5125 if Self::can_cast(syntax.kind()) {
5126 Some(Self { syntax })
5127 } else {
5128 None
5129 }
5130 }
5131 fn syntax(&self) -> &SyntaxNode {
5132 &self.syntax
5133 }
5134}
5135impl ast::AttrsOwner for TryExpr {}
5136impl TryExpr {
5137 pub fn try_kw(&self) -> Option<TryKw> {
5138 support::token(&self.syntax)
5139 }
5140 pub fn expr(&self) -> Option<Expr> {
5141 support::child(&self.syntax)
5142 }
5143}
5144#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5145pub struct CastExpr {
5146 pub(crate) syntax: SyntaxNode,
5147}
5148impl std::fmt::Display for CastExpr {
5149 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5150 std::fmt::Display::fmt(self.syntax(), f)
5151 }
5152}
5153impl AstNode for CastExpr {
5154 fn can_cast(kind: SyntaxKind) -> bool {
5155 match kind {
5156 CAST_EXPR => true,
5157 _ => false,
5158 }
5159 }
5160 fn cast(syntax: SyntaxNode) -> Option<Self> {
5161 if Self::can_cast(syntax.kind()) {
5162 Some(Self { syntax })
5163 } else {
5164 None
5165 }
5166 }
5167 fn syntax(&self) -> &SyntaxNode {
5168 &self.syntax
5169 }
5170}
5171impl ast::AttrsOwner for CastExpr {}
5172impl CastExpr {
5173 pub fn expr(&self) -> Option<Expr> {
5174 support::child(&self.syntax)
5175 }
5176 pub fn as_kw(&self) -> Option<AsKw> {
5177 support::token(&self.syntax)
5178 }
5179 pub fn type_ref(&self) -> Option<TypeRef> {
5180 support::child(&self.syntax)
5181 }
5182}
5183#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5184pub struct RefExpr {
5185 pub(crate) syntax: SyntaxNode,
5186}
5187impl std::fmt::Display for RefExpr {
5188 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5189 std::fmt::Display::fmt(self.syntax(), f)
5190 }
5191}
5192impl AstNode for RefExpr {
5193 fn can_cast(kind: SyntaxKind) -> bool {
5194 match kind {
5195 REF_EXPR => true,
5196 _ => false,
5197 }
5198 }
5199 fn cast(syntax: SyntaxNode) -> Option<Self> {
5200 if Self::can_cast(syntax.kind()) {
5201 Some(Self { syntax })
5202 } else {
5203 None
5204 }
5205 }
5206 fn syntax(&self) -> &SyntaxNode {
5207 &self.syntax
5208 }
5209}
5210impl ast::AttrsOwner for RefExpr {}
5211impl RefExpr {
5212 pub fn amp(&self) -> Option<Amp> {
5213 support::token(&self.syntax)
5214 }
5215 pub fn raw_kw(&self) -> Option<RawKw> {
5216 support::token(&self.syntax)
5217 }
5218 pub fn mut_kw(&self) -> Option<MutKw> {
5219 support::token(&self.syntax)
5220 }
5221 pub fn expr(&self) -> Option<Expr> {
5222 support::child(&self.syntax)
5223 }
5224}
5225#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5226pub struct PrefixExpr {
5227 pub(crate) syntax: SyntaxNode,
5228}
5229impl std::fmt::Display for PrefixExpr {
5230 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5231 std::fmt::Display::fmt(self.syntax(), f)
5232 }
5233}
5234impl AstNode for PrefixExpr {
5235 fn can_cast(kind: SyntaxKind) -> bool {
5236 match kind {
5237 PREFIX_EXPR => true,
5238 _ => false,
5239 }
5240 }
5241 fn cast(syntax: SyntaxNode) -> Option<Self> {
5242 if Self::can_cast(syntax.kind()) {
5243 Some(Self { syntax })
5244 } else {
5245 None
5246 }
5247 }
5248 fn syntax(&self) -> &SyntaxNode {
5249 &self.syntax
5250 }
5251}
5252impl ast::AttrsOwner for PrefixExpr {}
5253impl PrefixExpr {
5254 pub fn prefix_op(&self) -> Option<PrefixOp> {
5255 support::token(&self.syntax)
5256 }
5257 pub fn expr(&self) -> Option<Expr> {
5258 support::child(&self.syntax)
5259 }
5260}
5261#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5262pub struct BoxExpr {
5263 pub(crate) syntax: SyntaxNode,
5264}
5265impl std::fmt::Display for BoxExpr {
5266 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5267 std::fmt::Display::fmt(self.syntax(), f)
5268 }
5269}
5270impl AstNode for BoxExpr {
5271 fn can_cast(kind: SyntaxKind) -> bool {
5272 match kind {
5273 BOX_EXPR => true,
5274 _ => false,
5275 }
5276 }
5277 fn cast(syntax: SyntaxNode) -> Option<Self> {
5278 if Self::can_cast(syntax.kind()) {
5279 Some(Self { syntax })
5280 } else {
5281 None
5282 }
5283 }
5284 fn syntax(&self) -> &SyntaxNode {
5285 &self.syntax
5286 }
5287}
5288impl ast::AttrsOwner for BoxExpr {}
5289impl BoxExpr {
5290 pub fn box_kw(&self) -> Option<BoxKw> {
5291 support::token(&self.syntax)
5292 }
5293 pub fn expr(&self) -> Option<Expr> {
5294 support::child(&self.syntax)
5295 }
5296}
5297#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5298pub struct RangeExpr {
5299 pub(crate) syntax: SyntaxNode,
5300}
5301impl std::fmt::Display for RangeExpr {
5302 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5303 std::fmt::Display::fmt(self.syntax(), f)
5304 }
5305}
5306impl AstNode for RangeExpr {
5307 fn can_cast(kind: SyntaxKind) -> bool {
5308 match kind {
5309 RANGE_EXPR => true,
5310 _ => false,
5311 }
5312 }
5313 fn cast(syntax: SyntaxNode) -> Option<Self> {
5314 if Self::can_cast(syntax.kind()) {
5315 Some(Self { syntax })
5316 } else {
5317 None
5318 }
5319 }
5320 fn syntax(&self) -> &SyntaxNode {
5321 &self.syntax
5322 }
5323}
5324impl ast::AttrsOwner for RangeExpr {}
5325impl RangeExpr {
5326 pub fn range_op(&self) -> Option<RangeOp> {
5327 support::token(&self.syntax)
5328 }
5329}
5330#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5331pub struct BinExpr {
5332 pub(crate) syntax: SyntaxNode,
5333}
5334impl std::fmt::Display for BinExpr {
5335 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5336 std::fmt::Display::fmt(self.syntax(), f)
5337 }
5338}
5339impl AstNode for BinExpr {
5340 fn can_cast(kind: SyntaxKind) -> bool {
5341 match kind {
5342 BIN_EXPR => true,
5343 _ => false,
5344 }
5345 }
5346 fn cast(syntax: SyntaxNode) -> Option<Self> {
5347 if Self::can_cast(syntax.kind()) {
5348 Some(Self { syntax })
5349 } else {
5350 None
5351 }
5352 }
5353 fn syntax(&self) -> &SyntaxNode {
5354 &self.syntax
5355 }
5356}
5357impl ast::AttrsOwner for BinExpr {}
5358impl BinExpr {
5359 pub fn bin_op(&self) -> Option<BinOp> {
5360 support::token(&self.syntax)
5361 }
5362}
5363#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5364pub struct Literal {
5365 pub(crate) syntax: SyntaxNode,
5366}
5367impl std::fmt::Display for Literal {
5368 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5369 std::fmt::Display::fmt(self.syntax(), f)
5370 }
5371}
5372impl AstNode for Literal {
5373 fn can_cast(kind: SyntaxKind) -> bool {
5374 match kind {
5375 LITERAL => true,
5376 _ => false,
5377 }
5378 }
5379 fn cast(syntax: SyntaxNode) -> Option<Self> {
5380 if Self::can_cast(syntax.kind()) {
5381 Some(Self { syntax })
5382 } else {
5383 None
5384 }
5385 }
5386 fn syntax(&self) -> &SyntaxNode {
5387 &self.syntax
5388 }
5389}
5390impl Literal {
5391 pub fn literal_token(&self) -> Option<LiteralToken> {
5392 support::token(&self.syntax)
5393 }
5394}
5395#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5396pub struct MatchExpr {
5397 pub(crate) syntax: SyntaxNode,
5398}
5399impl std::fmt::Display for MatchExpr {
5400 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5401 std::fmt::Display::fmt(self.syntax(), f)
5402 }
5403}
5404impl AstNode for MatchExpr {
5405 fn can_cast(kind: SyntaxKind) -> bool {
5406 match kind {
5407 MATCH_EXPR => true,
5408 _ => false,
5409 }
5410 }
5411 fn cast(syntax: SyntaxNode) -> Option<Self> {
5412 if Self::can_cast(syntax.kind()) {
5413 Some(Self { syntax })
5414 } else {
5415 None
5416 }
5417 }
5418 fn syntax(&self) -> &SyntaxNode {
5419 &self.syntax
5420 }
5421}
5422impl ast::AttrsOwner for MatchExpr {}
5423impl MatchExpr {
5424 pub fn match_kw(&self) -> Option<MatchKw> {
5425 support::token(&self.syntax)
5426 }
5427 pub fn expr(&self) -> Option<Expr> {
5428 support::child(&self.syntax)
5429 }
5430 pub fn match_arm_list(&self) -> Option<MatchArmList> {
5431 support::child(&self.syntax)
5432 }
5433}
5434#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5435pub struct MatchArmList {
5436 pub(crate) syntax: SyntaxNode,
5437}
5438impl std::fmt::Display for MatchArmList {
5439 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5440 std::fmt::Display::fmt(self.syntax(), f)
5441 }
5442}
5443impl AstNode for MatchArmList {
5444 fn can_cast(kind: SyntaxKind) -> bool {
5445 match kind {
5446 MATCH_ARM_LIST => true,
5447 _ => false,
5448 }
5449 }
5450 fn cast(syntax: SyntaxNode) -> Option<Self> {
5451 if Self::can_cast(syntax.kind()) {
5452 Some(Self { syntax })
5453 } else {
5454 None
5455 }
5456 }
5457 fn syntax(&self) -> &SyntaxNode {
5458 &self.syntax
5459 }
5460}
5461impl ast::AttrsOwner for MatchArmList {}
5462impl MatchArmList {
5463 pub fn l_curly(&self) -> Option<LCurly> {
5464 support::token(&self.syntax)
5465 }
5466 pub fn arms(&self) -> AstChildren<MatchArm> {
5467 support::children(&self.syntax)
5468 }
5469 pub fn r_curly(&self) -> Option<RCurly> {
5470 support::token(&self.syntax)
5471 }
5472}
5473#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5474pub struct MatchArm {
5475 pub(crate) syntax: SyntaxNode,
5476}
5477impl std::fmt::Display for MatchArm {
5478 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5479 std::fmt::Display::fmt(self.syntax(), f)
5480 }
5481}
5482impl AstNode for MatchArm {
5483 fn can_cast(kind: SyntaxKind) -> bool {
5484 match kind {
5485 MATCH_ARM => true,
5486 _ => false,
5487 }
5488 }
5489 fn cast(syntax: SyntaxNode) -> Option<Self> {
5490 if Self::can_cast(syntax.kind()) {
5491 Some(Self { syntax })
5492 } else {
5493 None
5494 }
5495 }
5496 fn syntax(&self) -> &SyntaxNode {
5497 &self.syntax
5498 }
5499}
5500impl ast::AttrsOwner for MatchArm {}
5501impl MatchArm {
5502 pub fn pat(&self) -> Option<Pat> {
5503 support::child(&self.syntax)
5504 }
5505 pub fn guard(&self) -> Option<MatchGuard> {
5506 support::child(&self.syntax)
5507 }
5508 pub fn fat_arrow(&self) -> Option<FatArrow> {
5509 support::token(&self.syntax)
5510 }
5511 pub fn expr(&self) -> Option<Expr> {
5512 support::child(&self.syntax)
5513 }
5514}
5515#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5516pub struct MatchGuard {
5517 pub(crate) syntax: SyntaxNode,
5518}
5519impl std::fmt::Display for MatchGuard {
5520 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5521 std::fmt::Display::fmt(self.syntax(), f)
5522 }
5523}
5524impl AstNode for MatchGuard {
5525 fn can_cast(kind: SyntaxKind) -> bool {
5526 match kind {
5527 MATCH_GUARD => true,
5528 _ => false,
5529 }
5530 }
5531 fn cast(syntax: SyntaxNode) -> Option<Self> {
5532 if Self::can_cast(syntax.kind()) {
5533 Some(Self { syntax })
5534 } else {
5535 None
5536 }
5537 }
5538 fn syntax(&self) -> &SyntaxNode {
5539 &self.syntax
5540 }
5541}
5542impl MatchGuard {
5543 pub fn if_kw(&self) -> Option<IfKw> {
5544 support::token(&self.syntax)
5545 }
5546 pub fn expr(&self) -> Option<Expr> {
5547 support::child(&self.syntax)
5548 }
5549}
5550#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5551pub struct RecordLit {
5552 pub(crate) syntax: SyntaxNode,
5553}
5554impl std::fmt::Display for RecordLit {
5555 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5556 std::fmt::Display::fmt(self.syntax(), f)
5557 }
5558}
5559impl AstNode for RecordLit {
5560 fn can_cast(kind: SyntaxKind) -> bool {
5561 match kind {
5562 RECORD_LIT => true,
5563 _ => false,
5564 }
5565 }
5566 fn cast(syntax: SyntaxNode) -> Option<Self> {
5567 if Self::can_cast(syntax.kind()) {
5568 Some(Self { syntax })
5569 } else {
5570 None
5571 }
5572 }
5573 fn syntax(&self) -> &SyntaxNode {
5574 &self.syntax
5575 }
5576}
5577impl RecordLit {
5578 pub fn path(&self) -> Option<Path> {
5579 support::child(&self.syntax)
5580 }
5581 pub fn record_field_list(&self) -> Option<RecordFieldList> {
5582 support::child(&self.syntax)
5583 }
5584}
5585#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5586pub struct RecordFieldList {
5587 pub(crate) syntax: SyntaxNode,
5588}
5589impl std::fmt::Display for RecordFieldList {
5590 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5591 std::fmt::Display::fmt(self.syntax(), f)
5592 }
5593}
5594impl AstNode for RecordFieldList {
5595 fn can_cast(kind: SyntaxKind) -> bool {
5596 match kind {
5597 RECORD_FIELD_LIST => true,
5598 _ => false,
5599 }
5600 }
5601 fn cast(syntax: SyntaxNode) -> Option<Self> {
5602 if Self::can_cast(syntax.kind()) {
5603 Some(Self { syntax })
5604 } else {
5605 None
5606 }
5607 }
5608 fn syntax(&self) -> &SyntaxNode {
5609 &self.syntax
5610 }
5611}
5612impl RecordFieldList {
5613 pub fn l_curly(&self) -> Option<LCurly> {
5614 support::token(&self.syntax)
5615 }
5616 pub fn fields(&self) -> AstChildren<RecordField> {
5617 support::children(&self.syntax)
5618 }
5619 pub fn dotdot(&self) -> Option<Dotdot> {
5620 support::token(&self.syntax)
5621 }
5622 pub fn spread(&self) -> Option<Expr> {
5623 support::child(&self.syntax)
5624 }
5625 pub fn r_curly(&self) -> Option<RCurly> {
5626 support::token(&self.syntax)
5627 }
5628}
5629#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5630pub struct RecordField {
5631 pub(crate) syntax: SyntaxNode,
5632}
5633impl std::fmt::Display for RecordField {
5634 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5635 std::fmt::Display::fmt(self.syntax(), f)
5636 }
5637}
5638impl AstNode for RecordField {
5639 fn can_cast(kind: SyntaxKind) -> bool {
5640 match kind {
5641 RECORD_FIELD => true,
5642 _ => false,
5643 }
5644 }
5645 fn cast(syntax: SyntaxNode) -> Option<Self> {
5646 if Self::can_cast(syntax.kind()) {
5647 Some(Self { syntax })
5648 } else {
5649 None
5650 }
5651 }
5652 fn syntax(&self) -> &SyntaxNode {
5653 &self.syntax
5654 }
5655}
5656impl ast::AttrsOwner for RecordField {}
5657impl RecordField {
5658 pub fn name_ref(&self) -> Option<NameRef> {
5659 support::child(&self.syntax)
5660 }
5661 pub fn colon(&self) -> Option<Colon> {
5662 support::token(&self.syntax)
5663 }
5664 pub fn expr(&self) -> Option<Expr> {
5665 support::child(&self.syntax)
5666 }
5667}
5668#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5669pub struct OrPat {
5670 pub(crate) syntax: SyntaxNode,
5671}
5672impl std::fmt::Display for OrPat {
5673 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5674 std::fmt::Display::fmt(self.syntax(), f)
5675 }
5676}
5677impl AstNode for OrPat {
5678 fn can_cast(kind: SyntaxKind) -> bool {
5679 match kind {
5680 OR_PAT => true,
5681 _ => false,
5682 }
5683 }
5684 fn cast(syntax: SyntaxNode) -> Option<Self> {
5685 if Self::can_cast(syntax.kind()) {
5686 Some(Self { syntax })
5687 } else {
5688 None
5689 }
5690 }
5691 fn syntax(&self) -> &SyntaxNode {
5692 &self.syntax
5693 }
5694}
5695impl OrPat {
5696 pub fn pats(&self) -> AstChildren<Pat> {
5697 support::children(&self.syntax)
5698 }
5699}
5700#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5701pub struct ParenPat {
5702 pub(crate) syntax: SyntaxNode,
5703}
5704impl std::fmt::Display for ParenPat {
5705 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5706 std::fmt::Display::fmt(self.syntax(), f)
5707 }
5708}
5709impl AstNode for ParenPat {
5710 fn can_cast(kind: SyntaxKind) -> bool {
5711 match kind {
5712 PAREN_PAT => true,
5713 _ => false,
5714 }
5715 }
5716 fn cast(syntax: SyntaxNode) -> Option<Self> {
5717 if Self::can_cast(syntax.kind()) {
5718 Some(Self { syntax })
5719 } else {
5720 None
5721 }
5722 }
5723 fn syntax(&self) -> &SyntaxNode {
5724 &self.syntax
5725 }
5726}
5727impl ParenPat {
5728 pub fn l_paren(&self) -> Option<LParen> {
5729 support::token(&self.syntax)
5730 }
5731 pub fn pat(&self) -> Option<Pat> {
5732 support::child(&self.syntax)
5733 }
5734 pub fn r_paren(&self) -> Option<RParen> {
5735 support::token(&self.syntax)
5736 }
5737}
5738#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5739pub struct RefPat {
5740 pub(crate) syntax: SyntaxNode,
5741}
5742impl std::fmt::Display for RefPat {
5743 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5744 std::fmt::Display::fmt(self.syntax(), f)
5745 }
5746}
5747impl AstNode for RefPat {
5748 fn can_cast(kind: SyntaxKind) -> bool {
5749 match kind {
5750 REF_PAT => true,
5751 _ => false,
5752 }
5753 }
5754 fn cast(syntax: SyntaxNode) -> Option<Self> {
5755 if Self::can_cast(syntax.kind()) {
5756 Some(Self { syntax })
5757 } else {
5758 None
5759 }
5760 }
5761 fn syntax(&self) -> &SyntaxNode {
5762 &self.syntax
5763 }
5764}
5765impl RefPat {
5766 pub fn amp(&self) -> Option<Amp> {
5767 support::token(&self.syntax)
5768 }
5769 pub fn mut_kw(&self) -> Option<MutKw> {
5770 support::token(&self.syntax)
5771 }
5772 pub fn pat(&self) -> Option<Pat> {
5773 support::child(&self.syntax)
5774 }
5775}
5776#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5777pub struct BoxPat {
5778 pub(crate) syntax: SyntaxNode,
5779}
5780impl std::fmt::Display for BoxPat {
5781 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5782 std::fmt::Display::fmt(self.syntax(), f)
5783 }
5784}
5785impl AstNode for BoxPat {
5786 fn can_cast(kind: SyntaxKind) -> bool {
5787 match kind {
5788 BOX_PAT => true,
5789 _ => false,
5790 }
5791 }
5792 fn cast(syntax: SyntaxNode) -> Option<Self> {
5793 if Self::can_cast(syntax.kind()) {
5794 Some(Self { syntax })
5795 } else {
5796 None
5797 }
5798 }
5799 fn syntax(&self) -> &SyntaxNode {
5800 &self.syntax
5801 }
5802}
5803impl BoxPat {
5804 pub fn box_kw(&self) -> Option<BoxKw> {
5805 support::token(&self.syntax)
5806 }
5807 pub fn pat(&self) -> Option<Pat> {
5808 support::child(&self.syntax)
5809 }
5810}
5811#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5812pub struct BindPat {
5813 pub(crate) syntax: SyntaxNode,
5814}
5815impl std::fmt::Display for BindPat {
5816 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5817 std::fmt::Display::fmt(self.syntax(), f)
5818 }
5819}
5820impl AstNode for BindPat {
5821 fn can_cast(kind: SyntaxKind) -> bool {
5822 match kind {
5823 BIND_PAT => true,
5824 _ => false,
5825 }
5826 }
5827 fn cast(syntax: SyntaxNode) -> Option<Self> {
5828 if Self::can_cast(syntax.kind()) {
5829 Some(Self { syntax })
5830 } else {
5831 None
5832 }
5833 }
5834 fn syntax(&self) -> &SyntaxNode {
5835 &self.syntax
5836 }
5837}
5838impl ast::AttrsOwner for BindPat {}
5839impl ast::NameOwner for BindPat {}
5840impl BindPat {
5841 pub fn ref_kw(&self) -> Option<RefKw> {
5842 support::token(&self.syntax)
5843 }
5844 pub fn mut_kw(&self) -> Option<MutKw> {
5845 support::token(&self.syntax)
5846 }
5847 pub fn pat(&self) -> Option<Pat> {
5848 support::child(&self.syntax)
5849 }
5850}
5851#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5852pub struct PlaceholderPat {
5853 pub(crate) syntax: SyntaxNode,
5854}
5855impl std::fmt::Display for PlaceholderPat {
5856 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5857 std::fmt::Display::fmt(self.syntax(), f)
5858 }
5859}
5860impl AstNode for PlaceholderPat {
5861 fn can_cast(kind: SyntaxKind) -> bool {
5862 match kind {
5863 PLACEHOLDER_PAT => true,
5864 _ => false,
5865 }
5866 }
5867 fn cast(syntax: SyntaxNode) -> Option<Self> {
5868 if Self::can_cast(syntax.kind()) {
5869 Some(Self { syntax })
5870 } else {
5871 None
5872 }
5873 }
5874 fn syntax(&self) -> &SyntaxNode {
5875 &self.syntax
5876 }
5877}
5878impl PlaceholderPat {
5879 pub fn underscore(&self) -> Option<Underscore> {
5880 support::token(&self.syntax)
5881 }
5882}
5883#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5884pub struct DotDotPat {
5885 pub(crate) syntax: SyntaxNode,
5886}
5887impl std::fmt::Display for DotDotPat {
5888 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5889 std::fmt::Display::fmt(self.syntax(), f)
5890 }
5891}
5892impl AstNode for DotDotPat {
5893 fn can_cast(kind: SyntaxKind) -> bool {
5894 match kind {
5895 DOT_DOT_PAT => true,
5896 _ => false,
5897 }
5898 }
5899 fn cast(syntax: SyntaxNode) -> Option<Self> {
5900 if Self::can_cast(syntax.kind()) {
5901 Some(Self { syntax })
5902 } else {
5903 None
5904 }
5905 }
5906 fn syntax(&self) -> &SyntaxNode {
5907 &self.syntax
5908 }
5909}
5910impl DotDotPat {
5911 pub fn dotdot(&self) -> Option<Dotdot> {
5912 support::token(&self.syntax)
5913 }
5914}
5915#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5916pub struct PathPat {
5917 pub(crate) syntax: SyntaxNode,
5918}
5919impl std::fmt::Display for PathPat {
5920 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5921 std::fmt::Display::fmt(self.syntax(), f)
5922 }
5923}
5924impl AstNode for PathPat {
5925 fn can_cast(kind: SyntaxKind) -> bool {
5926 match kind {
5927 PATH_PAT => true,
5928 _ => false,
5929 }
5930 }
5931 fn cast(syntax: SyntaxNode) -> Option<Self> {
5932 if Self::can_cast(syntax.kind()) {
5933 Some(Self { syntax })
5934 } else {
5935 None
5936 }
5937 }
5938 fn syntax(&self) -> &SyntaxNode {
5939 &self.syntax
5940 }
5941}
5942impl PathPat {
5943 pub fn path(&self) -> Option<Path> {
5944 support::child(&self.syntax)
5945 }
5946}
5947#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5948pub struct SlicePat {
5949 pub(crate) syntax: SyntaxNode,
5950}
5951impl std::fmt::Display for SlicePat {
5952 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5953 std::fmt::Display::fmt(self.syntax(), f)
5954 }
5955}
5956impl AstNode for SlicePat {
5957 fn can_cast(kind: SyntaxKind) -> bool {
5958 match kind {
5959 SLICE_PAT => true,
5960 _ => false,
5961 }
5962 }
5963 fn cast(syntax: SyntaxNode) -> Option<Self> {
5964 if Self::can_cast(syntax.kind()) {
5965 Some(Self { syntax })
5966 } else {
5967 None
5968 }
5969 }
5970 fn syntax(&self) -> &SyntaxNode {
5971 &self.syntax
5972 }
5973}
5974impl SlicePat {
5975 pub fn l_brack(&self) -> Option<LBrack> {
5976 support::token(&self.syntax)
5977 }
5978 pub fn args(&self) -> AstChildren<Pat> {
5979 support::children(&self.syntax)
5980 }
5981 pub fn r_brack(&self) -> Option<RBrack> {
5982 support::token(&self.syntax)
5983 }
5984}
5985#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5986pub struct RangePat {
5987 pub(crate) syntax: SyntaxNode,
5988}
5989impl std::fmt::Display for RangePat {
5990 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5991 std::fmt::Display::fmt(self.syntax(), f)
5992 }
5993}
5994impl AstNode for RangePat {
5995 fn can_cast(kind: SyntaxKind) -> bool {
5996 match kind {
5997 RANGE_PAT => true,
5998 _ => false,
5999 }
6000 }
6001 fn cast(syntax: SyntaxNode) -> Option<Self> {
6002 if Self::can_cast(syntax.kind()) {
6003 Some(Self { syntax })
6004 } else {
6005 None
6006 }
6007 }
6008 fn syntax(&self) -> &SyntaxNode {
6009 &self.syntax
6010 }
6011}
6012impl RangePat {
6013 pub fn range_separator(&self) -> Option<RangeSeparator> {
6014 support::token(&self.syntax)
6015 }
6016}
6017#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6018pub struct LiteralPat {
6019 pub(crate) syntax: SyntaxNode,
6020}
6021impl std::fmt::Display for LiteralPat {
6022 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6023 std::fmt::Display::fmt(self.syntax(), f)
6024 }
6025}
6026impl AstNode for LiteralPat {
6027 fn can_cast(kind: SyntaxKind) -> bool {
6028 match kind {
6029 LITERAL_PAT => true,
6030 _ => false,
6031 }
6032 }
6033 fn cast(syntax: SyntaxNode) -> Option<Self> {
6034 if Self::can_cast(syntax.kind()) {
6035 Some(Self { syntax })
6036 } else {
6037 None
6038 }
6039 }
6040 fn syntax(&self) -> &SyntaxNode {
6041 &self.syntax
6042 }
6043}
6044impl LiteralPat {
6045 pub fn literal(&self) -> Option<Literal> {
6046 support::child(&self.syntax)
6047 }
6048}
6049#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6050pub struct MacroPat {
6051 pub(crate) syntax: SyntaxNode,
6052}
6053impl std::fmt::Display for MacroPat {
6054 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6055 std::fmt::Display::fmt(self.syntax(), f)
6056 }
6057}
6058impl AstNode for MacroPat {
6059 fn can_cast(kind: SyntaxKind) -> bool {
6060 match kind {
6061 MACRO_PAT => true,
6062 _ => false,
6063 }
6064 }
6065 fn cast(syntax: SyntaxNode) -> Option<Self> {
6066 if Self::can_cast(syntax.kind()) {
6067 Some(Self { syntax })
6068 } else {
6069 None
6070 }
6071 }
6072 fn syntax(&self) -> &SyntaxNode {
6073 &self.syntax
6074 }
6075}
6076impl MacroPat {
6077 pub fn macro_call(&self) -> Option<MacroCall> {
6078 support::child(&self.syntax)
6079 }
6080}
6081#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6082pub struct RecordPat {
6083 pub(crate) syntax: SyntaxNode,
6084}
6085impl std::fmt::Display for RecordPat {
6086 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6087 std::fmt::Display::fmt(self.syntax(), f)
6088 }
6089}
6090impl AstNode for RecordPat {
6091 fn can_cast(kind: SyntaxKind) -> bool {
6092 match kind {
6093 RECORD_PAT => true,
6094 _ => false,
6095 }
6096 }
6097 fn cast(syntax: SyntaxNode) -> Option<Self> {
6098 if Self::can_cast(syntax.kind()) {
6099 Some(Self { syntax })
6100 } else {
6101 None
6102 }
6103 }
6104 fn syntax(&self) -> &SyntaxNode {
6105 &self.syntax
6106 }
6107}
6108impl RecordPat {
6109 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
6110 support::child(&self.syntax)
6111 }
6112 pub fn path(&self) -> Option<Path> {
6113 support::child(&self.syntax)
6114 }
6115}
6116#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6117pub struct RecordFieldPatList {
6118 pub(crate) syntax: SyntaxNode,
6119}
6120impl std::fmt::Display for RecordFieldPatList {
6121 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6122 std::fmt::Display::fmt(self.syntax(), f)
6123 }
6124}
6125impl AstNode for RecordFieldPatList {
6126 fn can_cast(kind: SyntaxKind) -> bool {
6127 match kind {
6128 RECORD_FIELD_PAT_LIST => true,
6129 _ => false,
6130 }
6131 }
6132 fn cast(syntax: SyntaxNode) -> Option<Self> {
6133 if Self::can_cast(syntax.kind()) {
6134 Some(Self { syntax })
6135 } else {
6136 None
6137 }
6138 }
6139 fn syntax(&self) -> &SyntaxNode {
6140 &self.syntax
6141 }
6142}
6143impl RecordFieldPatList {
6144 pub fn l_curly(&self) -> Option<LCurly> {
6145 support::token(&self.syntax)
6146 }
6147 pub fn pats(&self) -> AstChildren<RecordInnerPat> {
6148 support::children(&self.syntax)
6149 }
6150 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
6151 support::children(&self.syntax)
6152 }
6153 pub fn bind_pats(&self) -> AstChildren<BindPat> {
6154 support::children(&self.syntax)
6155 }
6156 pub fn dotdot(&self) -> Option<Dotdot> {
6157 support::token(&self.syntax)
6158 }
6159 pub fn r_curly(&self) -> Option<RCurly> {
6160 support::token(&self.syntax)
6161 }
6162}
6163#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6164pub struct RecordFieldPat {
6165 pub(crate) syntax: SyntaxNode,
6166}
6167impl std::fmt::Display for RecordFieldPat {
6168 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6169 std::fmt::Display::fmt(self.syntax(), f)
6170 }
6171}
6172impl AstNode for RecordFieldPat {
6173 fn can_cast(kind: SyntaxKind) -> bool {
6174 match kind {
6175 RECORD_FIELD_PAT => true,
6176 _ => false,
6177 }
6178 }
6179 fn cast(syntax: SyntaxNode) -> Option<Self> {
6180 if Self::can_cast(syntax.kind()) {
6181 Some(Self { syntax })
6182 } else {
6183 None
6184 }
6185 }
6186 fn syntax(&self) -> &SyntaxNode {
6187 &self.syntax
6188 }
6189}
6190impl ast::AttrsOwner for RecordFieldPat {}
6191impl ast::NameOwner for RecordFieldPat {}
6192impl RecordFieldPat {
6193 pub fn colon(&self) -> Option<Colon> {
6194 support::token(&self.syntax)
6195 }
6196 pub fn pat(&self) -> Option<Pat> {
6197 support::child(&self.syntax)
6198 }
6199}
6200#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6201pub struct TupleStructPat {
6202 pub(crate) syntax: SyntaxNode,
6203}
6204impl std::fmt::Display for TupleStructPat {
6205 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6206 std::fmt::Display::fmt(self.syntax(), f)
6207 }
6208}
6209impl AstNode for TupleStructPat {
6210 fn can_cast(kind: SyntaxKind) -> bool {
6211 match kind {
6212 TUPLE_STRUCT_PAT => true,
6213 _ => false,
6214 }
6215 }
6216 fn cast(syntax: SyntaxNode) -> Option<Self> {
6217 if Self::can_cast(syntax.kind()) {
6218 Some(Self { syntax })
6219 } else {
6220 None
6221 }
6222 }
6223 fn syntax(&self) -> &SyntaxNode {
6224 &self.syntax
6225 }
6226}
6227impl TupleStructPat {
6228 pub fn path(&self) -> Option<Path> {
6229 support::child(&self.syntax)
6230 }
6231 pub fn l_paren(&self) -> Option<LParen> {
6232 support::token(&self.syntax)
6233 }
6234 pub fn args(&self) -> AstChildren<Pat> {
6235 support::children(&self.syntax)
6236 }
6237 pub fn r_paren(&self) -> Option<RParen> {
6238 support::token(&self.syntax)
6239 }
6240}
6241#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6242pub struct TuplePat {
6243 pub(crate) syntax: SyntaxNode,
6244}
6245impl std::fmt::Display for TuplePat {
6246 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6247 std::fmt::Display::fmt(self.syntax(), f)
6248 }
6249}
6250impl AstNode for TuplePat {
6251 fn can_cast(kind: SyntaxKind) -> bool {
6252 match kind {
6253 TUPLE_PAT => true,
6254 _ => false,
6255 }
6256 }
6257 fn cast(syntax: SyntaxNode) -> Option<Self> {
6258 if Self::can_cast(syntax.kind()) {
6259 Some(Self { syntax })
6260 } else {
6261 None
6262 }
6263 }
6264 fn syntax(&self) -> &SyntaxNode {
6265 &self.syntax
6266 }
6267}
6268impl TuplePat {
6269 pub fn l_paren(&self) -> Option<LParen> {
6270 support::token(&self.syntax)
6271 }
6272 pub fn args(&self) -> AstChildren<Pat> {
6273 support::children(&self.syntax)
6274 }
6275 pub fn r_paren(&self) -> Option<RParen> {
6276 support::token(&self.syntax)
6277 }
6278}
6279#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6280pub struct Visibility {
6281 pub(crate) syntax: SyntaxNode,
6282}
6283impl std::fmt::Display for Visibility {
6284 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6285 std::fmt::Display::fmt(self.syntax(), f)
6286 }
6287}
6288impl AstNode for Visibility {
6289 fn can_cast(kind: SyntaxKind) -> bool {
6290 match kind {
6291 VISIBILITY => true,
6292 _ => false,
6293 }
6294 }
6295 fn cast(syntax: SyntaxNode) -> Option<Self> {
6296 if Self::can_cast(syntax.kind()) {
6297 Some(Self { syntax })
6298 } else {
6299 None
6300 }
6301 }
6302 fn syntax(&self) -> &SyntaxNode {
6303 &self.syntax
6304 }
6305}
6306impl Visibility {
6307 pub fn pub_kw(&self) -> Option<PubKw> {
6308 support::token(&self.syntax)
6309 }
6310 pub fn super_kw(&self) -> Option<SuperKw> {
6311 support::token(&self.syntax)
6312 }
6313 pub fn self_kw(&self) -> Option<SelfKw> {
6314 support::token(&self.syntax)
6315 }
6316 pub fn crate_kw(&self) -> Option<CrateKw> {
6317 support::token(&self.syntax)
6318 }
6319}
6320#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6321pub struct Name {
6322 pub(crate) syntax: SyntaxNode,
6323}
6324impl std::fmt::Display for Name {
6325 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6326 std::fmt::Display::fmt(self.syntax(), f)
6327 }
6328}
6329impl AstNode for Name {
6330 fn can_cast(kind: SyntaxKind) -> bool {
6331 match kind {
6332 NAME => true,
6333 _ => false,
6334 }
6335 }
6336 fn cast(syntax: SyntaxNode) -> Option<Self> {
6337 if Self::can_cast(syntax.kind()) {
6338 Some(Self { syntax })
6339 } else {
6340 None
6341 }
6342 }
6343 fn syntax(&self) -> &SyntaxNode {
6344 &self.syntax
6345 }
6346}
6347impl Name {
6348 pub fn ident(&self) -> Option<Ident> {
6349 support::token(&self.syntax)
6350 }
6351}
6352#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6353pub struct NameRef {
6354 pub(crate) syntax: SyntaxNode,
6355}
6356impl std::fmt::Display for NameRef {
6357 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6358 std::fmt::Display::fmt(self.syntax(), f)
6359 }
6360}
6361impl AstNode for NameRef {
6362 fn can_cast(kind: SyntaxKind) -> bool {
6363 match kind {
6364 NAME_REF => true,
6365 _ => false,
6366 }
6367 }
6368 fn cast(syntax: SyntaxNode) -> Option<Self> {
6369 if Self::can_cast(syntax.kind()) {
6370 Some(Self { syntax })
6371 } else {
6372 None
6373 }
6374 }
6375 fn syntax(&self) -> &SyntaxNode {
6376 &self.syntax
6377 }
6378}
6379impl NameRef {
6380 pub fn name_ref_token(&self) -> Option<NameRefToken> {
6381 support::token(&self.syntax)
6382 }
6383}
6384#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6385pub struct MacroCall {
6386 pub(crate) syntax: SyntaxNode,
6387}
6388impl std::fmt::Display for MacroCall {
6389 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6390 std::fmt::Display::fmt(self.syntax(), f)
6391 }
6392}
6393impl AstNode for MacroCall {
6394 fn can_cast(kind: SyntaxKind) -> bool {
6395 match kind {
6396 MACRO_CALL => true,
6397 _ => false,
6398 }
6399 }
6400 fn cast(syntax: SyntaxNode) -> Option<Self> {
6401 if Self::can_cast(syntax.kind()) {
6402 Some(Self { syntax })
6403 } else {
6404 None
6405 }
6406 }
6407 fn syntax(&self) -> &SyntaxNode {
6408 &self.syntax
6409 }
6410}
6411impl ast::NameOwner for MacroCall {}
6412impl ast::AttrsOwner for MacroCall {}
6413impl ast::DocCommentsOwner for MacroCall {}
6414impl MacroCall {
6415 pub fn path(&self) -> Option<Path> {
6416 support::child(&self.syntax)
6417 }
6418 pub fn excl(&self) -> Option<Excl> {
6419 support::token(&self.syntax)
6420 }
6421 pub fn token_tree(&self) -> Option<TokenTree> {
6422 support::child(&self.syntax)
6423 }
6424 pub fn semi(&self) -> Option<Semi> {
6425 support::token(&self.syntax)
6426 }
6427}
6428#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6429pub struct Attr {
6430 pub(crate) syntax: SyntaxNode,
6431}
6432impl std::fmt::Display for Attr {
6433 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6434 std::fmt::Display::fmt(self.syntax(), f)
6435 }
6436}
6437impl AstNode for Attr {
6438 fn can_cast(kind: SyntaxKind) -> bool {
6439 match kind {
6440 ATTR => true,
6441 _ => false,
6442 }
6443 }
6444 fn cast(syntax: SyntaxNode) -> Option<Self> {
6445 if Self::can_cast(syntax.kind()) {
6446 Some(Self { syntax })
6447 } else {
6448 None
6449 }
6450 }
6451 fn syntax(&self) -> &SyntaxNode {
6452 &self.syntax
6453 }
6454}
6455impl Attr {
6456 pub fn pound(&self) -> Option<Pound> {
6457 support::token(&self.syntax)
6458 }
6459 pub fn excl(&self) -> Option<Excl> {
6460 support::token(&self.syntax)
6461 }
6462 pub fn l_brack(&self) -> Option<LBrack> {
6463 support::token(&self.syntax)
6464 }
6465 pub fn path(&self) -> Option<Path> {
6466 support::child(&self.syntax)
6467 }
6468 pub fn eq(&self) -> Option<Eq> {
6469 support::token(&self.syntax)
6470 }
6471 pub fn input(&self) -> Option<AttrInput> {
6472 support::child(&self.syntax)
6473 }
6474 pub fn r_brack(&self) -> Option<RBrack> {
6475 support::token(&self.syntax)
6476 }
6477}
6478#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6479pub struct TokenTree {
6480 pub(crate) syntax: SyntaxNode,
6481}
6482impl std::fmt::Display for TokenTree {
6483 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6484 std::fmt::Display::fmt(self.syntax(), f)
6485 }
6486}
6487impl AstNode for TokenTree {
6488 fn can_cast(kind: SyntaxKind) -> bool {
6489 match kind {
6490 TOKEN_TREE => true,
6491 _ => false,
6492 }
6493 }
6494 fn cast(syntax: SyntaxNode) -> Option<Self> {
6495 if Self::can_cast(syntax.kind()) {
6496 Some(Self { syntax })
6497 } else {
6498 None
6499 }
6500 }
6501 fn syntax(&self) -> &SyntaxNode {
6502 &self.syntax
6503 }
6504}
6505impl TokenTree {}
6506#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6507pub struct TypeParamList {
6508 pub(crate) syntax: SyntaxNode,
6509}
6510impl std::fmt::Display for TypeParamList {
6511 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6512 std::fmt::Display::fmt(self.syntax(), f)
6513 }
6514}
6515impl AstNode for TypeParamList {
6516 fn can_cast(kind: SyntaxKind) -> bool {
6517 match kind {
6518 TYPE_PARAM_LIST => true,
6519 _ => false,
6520 }
6521 }
6522 fn cast(syntax: SyntaxNode) -> Option<Self> {
6523 if Self::can_cast(syntax.kind()) {
6524 Some(Self { syntax })
6525 } else {
6526 None
6527 }
6528 }
6529 fn syntax(&self) -> &SyntaxNode {
6530 &self.syntax
6531 }
6532}
6533impl TypeParamList {
6534 pub fn l_angle(&self) -> Option<LAngle> {
6535 support::token(&self.syntax)
6536 }
6537 pub fn generic_params(&self) -> AstChildren<GenericParam> {
6538 support::children(&self.syntax)
6539 }
6540 pub fn type_params(&self) -> AstChildren<TypeParam> {
6541 support::children(&self.syntax)
6542 }
6543 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> {
6544 support::children(&self.syntax)
6545 }
6546 pub fn const_params(&self) -> AstChildren<ConstParam> {
6547 support::children(&self.syntax)
6548 }
6549 pub fn r_angle(&self) -> Option<RAngle> {
6550 support::token(&self.syntax)
6551 }
6552}
6553#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6554pub struct TypeParam {
6555 pub(crate) syntax: SyntaxNode,
6556}
6557impl std::fmt::Display for TypeParam {
6558 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6559 std::fmt::Display::fmt(self.syntax(), f)
6560 }
6561}
6562impl AstNode for TypeParam {
6563 fn can_cast(kind: SyntaxKind) -> bool {
6564 match kind {
6565 TYPE_PARAM => true,
6566 _ => false,
6567 }
6568 }
6569 fn cast(syntax: SyntaxNode) -> Option<Self> {
6570 if Self::can_cast(syntax.kind()) {
6571 Some(Self { syntax })
6572 } else {
6573 None
6574 }
6575 }
6576 fn syntax(&self) -> &SyntaxNode {
6577 &self.syntax
6578 }
6579}
6580impl ast::NameOwner for TypeParam {}
6581impl ast::AttrsOwner for TypeParam {}
6582impl ast::TypeBoundsOwner for TypeParam {}
6583impl TypeParam {
6584 pub fn eq(&self) -> Option<Eq> {
6585 support::token(&self.syntax)
6586 }
6587 pub fn default_type(&self) -> Option<TypeRef> {
6588 support::child(&self.syntax)
6589 }
6590}
6591#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6592pub struct ConstParam {
6593 pub(crate) syntax: SyntaxNode,
6594}
6595impl std::fmt::Display for ConstParam {
6596 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6597 std::fmt::Display::fmt(self.syntax(), f)
6598 }
6599}
6600impl AstNode for ConstParam {
6601 fn can_cast(kind: SyntaxKind) -> bool {
6602 match kind {
6603 CONST_PARAM => true,
6604 _ => false,
6605 }
6606 }
6607 fn cast(syntax: SyntaxNode) -> Option<Self> {
6608 if Self::can_cast(syntax.kind()) {
6609 Some(Self { syntax })
6610 } else {
6611 None
6612 }
6613 }
6614 fn syntax(&self) -> &SyntaxNode {
6615 &self.syntax
6616 }
6617}
6618impl ast::NameOwner for ConstParam {}
6619impl ast::AttrsOwner for ConstParam {}
6620impl ast::TypeAscriptionOwner for ConstParam {}
6621impl ConstParam {
6622 pub fn eq(&self) -> Option<Eq> {
6623 support::token(&self.syntax)
6624 }
6625 pub fn default_val(&self) -> Option<Expr> {
6626 support::child(&self.syntax)
6627 }
6628}
6629#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6630pub struct LifetimeParam {
6631 pub(crate) syntax: SyntaxNode,
6632}
6633impl std::fmt::Display for LifetimeParam {
6634 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6635 std::fmt::Display::fmt(self.syntax(), f)
6636 }
6637}
6638impl AstNode for LifetimeParam {
6639 fn can_cast(kind: SyntaxKind) -> bool {
6640 match kind {
6641 LIFETIME_PARAM => true,
6642 _ => false,
6643 }
6644 }
6645 fn cast(syntax: SyntaxNode) -> Option<Self> {
6646 if Self::can_cast(syntax.kind()) {
6647 Some(Self { syntax })
6648 } else {
6649 None
6650 }
6651 }
6652 fn syntax(&self) -> &SyntaxNode {
6653 &self.syntax
6654 }
6655}
6656impl ast::AttrsOwner for LifetimeParam {}
6657impl LifetimeParam {
6658 pub fn lifetime(&self) -> Option<Lifetime> {
6659 support::token(&self.syntax)
6660 }
6661}
6662#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6663pub struct TypeBound {
6664 pub(crate) syntax: SyntaxNode,
6665}
6666impl std::fmt::Display for TypeBound {
6667 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6668 std::fmt::Display::fmt(self.syntax(), f)
6669 }
6670}
6671impl AstNode for TypeBound {
6672 fn can_cast(kind: SyntaxKind) -> bool {
6673 match kind {
6674 TYPE_BOUND => true,
6675 _ => false,
6676 }
6677 }
6678 fn cast(syntax: SyntaxNode) -> Option<Self> {
6679 if Self::can_cast(syntax.kind()) {
6680 Some(Self { syntax })
6681 } else {
6682 None
6683 }
6684 }
6685 fn syntax(&self) -> &SyntaxNode {
6686 &self.syntax
6687 }
6688}
6689impl TypeBound {
6690 pub fn lifetime(&self) -> Option<Lifetime> {
6691 support::token(&self.syntax)
6692 }
6693 pub fn const_kw(&self) -> Option<ConstKw> {
6694 support::token(&self.syntax)
6695 }
6696 pub fn type_ref(&self) -> Option<TypeRef> {
6697 support::child(&self.syntax)
6698 }
6699}
6700#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6701pub struct TypeBoundList {
6702 pub(crate) syntax: SyntaxNode,
6703}
6704impl std::fmt::Display for TypeBoundList {
6705 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6706 std::fmt::Display::fmt(self.syntax(), f)
6707 }
6708}
6709impl AstNode for TypeBoundList {
6710 fn can_cast(kind: SyntaxKind) -> bool {
6711 match kind {
6712 TYPE_BOUND_LIST => true,
6713 _ => false,
6714 }
6715 }
6716 fn cast(syntax: SyntaxNode) -> Option<Self> {
6717 if Self::can_cast(syntax.kind()) {
6718 Some(Self { syntax })
6719 } else {
6720 None
6721 }
6722 }
6723 fn syntax(&self) -> &SyntaxNode {
6724 &self.syntax
6725 }
6726}
6727impl TypeBoundList {
6728 pub fn bounds(&self) -> AstChildren<TypeBound> {
6729 support::children(&self.syntax)
6730 }
6731}
6732#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6733pub struct WherePred {
6734 pub(crate) syntax: SyntaxNode,
6735}
6736impl std::fmt::Display for WherePred {
6737 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6738 std::fmt::Display::fmt(self.syntax(), f)
6739 }
6740}
6741impl AstNode for WherePred {
6742 fn can_cast(kind: SyntaxKind) -> bool {
6743 match kind {
6744 WHERE_PRED => true,
6745 _ => false,
6746 }
6747 }
6748 fn cast(syntax: SyntaxNode) -> Option<Self> {
6749 if Self::can_cast(syntax.kind()) {
6750 Some(Self { syntax })
6751 } else {
6752 None
6753 }
6754 }
6755 fn syntax(&self) -> &SyntaxNode {
6756 &self.syntax
6757 }
6758}
6759impl ast::TypeBoundsOwner for WherePred {}
6760impl WherePred {
6761 pub fn lifetime(&self) -> Option<Lifetime> {
6762 support::token(&self.syntax)
6763 }
6764 pub fn type_ref(&self) -> Option<TypeRef> {
6765 support::child(&self.syntax)
6766 }
6767}
6768#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6769pub struct WhereClause {
6770 pub(crate) syntax: SyntaxNode,
6771}
6772impl std::fmt::Display for WhereClause {
6773 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6774 std::fmt::Display::fmt(self.syntax(), f)
6775 }
6776}
6777impl AstNode for WhereClause {
6778 fn can_cast(kind: SyntaxKind) -> bool {
6779 match kind {
6780 WHERE_CLAUSE => true,
6781 _ => false,
6782 }
6783 }
6784 fn cast(syntax: SyntaxNode) -> Option<Self> {
6785 if Self::can_cast(syntax.kind()) {
6786 Some(Self { syntax })
6787 } else {
6788 None
6789 }
6790 }
6791 fn syntax(&self) -> &SyntaxNode {
6792 &self.syntax
6793 }
6794}
6795impl WhereClause {
6796 pub fn where_kw(&self) -> Option<WhereKw> {
6797 support::token(&self.syntax)
6798 }
6799 pub fn predicates(&self) -> AstChildren<WherePred> {
6800 support::children(&self.syntax)
6801 }
6802}
6803#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6804pub struct Abi {
6805 pub(crate) syntax: SyntaxNode,
6806}
6807impl std::fmt::Display for Abi {
6808 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6809 std::fmt::Display::fmt(self.syntax(), f)
6810 }
6811}
6812impl AstNode for Abi {
6813 fn can_cast(kind: SyntaxKind) -> bool {
6814 match kind {
6815 ABI => true,
6816 _ => false,
6817 }
6818 }
6819 fn cast(syntax: SyntaxNode) -> Option<Self> {
6820 if Self::can_cast(syntax.kind()) {
6821 Some(Self { syntax })
6822 } else {
6823 None
6824 }
6825 }
6826 fn syntax(&self) -> &SyntaxNode {
6827 &self.syntax
6828 }
6829}
6830impl Abi {
6831 pub fn string(&self) -> Option<String> {
6832 support::token(&self.syntax)
6833 }
6834}
6835#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6836pub struct ExprStmt {
6837 pub(crate) syntax: SyntaxNode,
6838}
6839impl std::fmt::Display for ExprStmt {
6840 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6841 std::fmt::Display::fmt(self.syntax(), f)
6842 }
6843}
6844impl AstNode for ExprStmt {
6845 fn can_cast(kind: SyntaxKind) -> bool {
6846 match kind {
6847 EXPR_STMT => true,
6848 _ => false,
6849 }
6850 }
6851 fn cast(syntax: SyntaxNode) -> Option<Self> {
6852 if Self::can_cast(syntax.kind()) {
6853 Some(Self { syntax })
6854 } else {
6855 None
6856 }
6857 }
6858 fn syntax(&self) -> &SyntaxNode {
6859 &self.syntax
6860 }
6861}
6862impl ast::AttrsOwner for ExprStmt {}
6863impl ExprStmt {
6864 pub fn expr(&self) -> Option<Expr> {
6865 support::child(&self.syntax)
6866 }
6867 pub fn semi(&self) -> Option<Semi> {
6868 support::token(&self.syntax)
6869 }
6870}
6871#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6872pub struct LetStmt {
6873 pub(crate) syntax: SyntaxNode,
6874}
6875impl std::fmt::Display for LetStmt {
6876 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6877 std::fmt::Display::fmt(self.syntax(), f)
6878 }
6879}
6880impl AstNode for LetStmt {
6881 fn can_cast(kind: SyntaxKind) -> bool {
6882 match kind {
6883 LET_STMT => true,
6884 _ => false,
6885 }
6886 }
6887 fn cast(syntax: SyntaxNode) -> Option<Self> {
6888 if Self::can_cast(syntax.kind()) {
6889 Some(Self { syntax })
6890 } else {
6891 None
6892 }
6893 }
6894 fn syntax(&self) -> &SyntaxNode {
6895 &self.syntax
6896 }
6897}
6898impl ast::AttrsOwner for LetStmt {}
6899impl ast::TypeAscriptionOwner for LetStmt {}
6900impl LetStmt {
6901 pub fn let_kw(&self) -> Option<LetKw> {
6902 support::token(&self.syntax)
6903 }
6904 pub fn pat(&self) -> Option<Pat> {
6905 support::child(&self.syntax)
6906 }
6907 pub fn eq(&self) -> Option<Eq> {
6908 support::token(&self.syntax)
6909 }
6910 pub fn initializer(&self) -> Option<Expr> {
6911 support::child(&self.syntax)
6912 }
6913}
6914#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6915pub struct Condition {
6916 pub(crate) syntax: SyntaxNode,
6917}
6918impl std::fmt::Display for Condition {
6919 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6920 std::fmt::Display::fmt(self.syntax(), f)
6921 }
6922}
6923impl AstNode for Condition {
6924 fn can_cast(kind: SyntaxKind) -> bool {
6925 match kind {
6926 CONDITION => true,
6927 _ => false,
6928 }
6929 }
6930 fn cast(syntax: SyntaxNode) -> Option<Self> {
6931 if Self::can_cast(syntax.kind()) {
6932 Some(Self { syntax })
6933 } else {
6934 None
6935 }
6936 }
6937 fn syntax(&self) -> &SyntaxNode {
6938 &self.syntax
6939 }
6940}
6941impl Condition {
6942 pub fn let_kw(&self) -> Option<LetKw> {
6943 support::token(&self.syntax)
6944 }
6945 pub fn pat(&self) -> Option<Pat> {
6946 support::child(&self.syntax)
6947 }
6948 pub fn eq(&self) -> Option<Eq> {
6949 support::token(&self.syntax)
6950 }
6951 pub fn expr(&self) -> Option<Expr> {
6952 support::child(&self.syntax)
6953 }
6954}
6955#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6956pub struct Block {
6957 pub(crate) syntax: SyntaxNode,
6958}
6959impl std::fmt::Display for Block {
6960 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6961 std::fmt::Display::fmt(self.syntax(), f)
6962 }
6963}
6964impl AstNode for Block {
6965 fn can_cast(kind: SyntaxKind) -> bool {
6966 match kind {
6967 BLOCK => true,
6968 _ => false,
6969 }
6970 }
6971 fn cast(syntax: SyntaxNode) -> Option<Self> {
6972 if Self::can_cast(syntax.kind()) {
6973 Some(Self { syntax })
6974 } else {
6975 None
6976 }
6977 }
6978 fn syntax(&self) -> &SyntaxNode {
6979 &self.syntax
6980 }
6981}
6982impl ast::AttrsOwner for Block {}
6983impl ast::ModuleItemOwner for Block {}
6984impl Block {
6985 pub fn l_curly(&self) -> Option<LCurly> {
6986 support::token(&self.syntax)
6987 }
6988 pub fn statements(&self) -> AstChildren<Stmt> {
6989 support::children(&self.syntax)
6990 }
6991 pub fn expr(&self) -> Option<Expr> {
6992 support::child(&self.syntax)
6993 }
6994 pub fn r_curly(&self) -> Option<RCurly> {
6995 support::token(&self.syntax)
6996 }
6997}
6998#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6999pub struct ParamList {
7000 pub(crate) syntax: SyntaxNode,
7001}
7002impl std::fmt::Display for ParamList {
7003 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7004 std::fmt::Display::fmt(self.syntax(), f)
7005 }
7006}
7007impl AstNode for ParamList {
7008 fn can_cast(kind: SyntaxKind) -> bool {
7009 match kind {
7010 PARAM_LIST => true,
7011 _ => false,
7012 }
7013 }
7014 fn cast(syntax: SyntaxNode) -> Option<Self> {
7015 if Self::can_cast(syntax.kind()) {
7016 Some(Self { syntax })
7017 } else {
7018 None
7019 }
7020 }
7021 fn syntax(&self) -> &SyntaxNode {
7022 &self.syntax
7023 }
7024}
7025impl ParamList {
7026 pub fn l_paren(&self) -> Option<LParen> {
7027 support::token(&self.syntax)
7028 }
7029 pub fn self_param(&self) -> Option<SelfParam> {
7030 support::child(&self.syntax)
7031 }
7032 pub fn params(&self) -> AstChildren<Param> {
7033 support::children(&self.syntax)
7034 }
7035 pub fn r_paren(&self) -> Option<RParen> {
7036 support::token(&self.syntax)
7037 }
7038}
7039#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7040pub struct SelfParam {
7041 pub(crate) syntax: SyntaxNode,
7042}
7043impl std::fmt::Display for SelfParam {
7044 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7045 std::fmt::Display::fmt(self.syntax(), f)
7046 }
7047}
7048impl AstNode for SelfParam {
7049 fn can_cast(kind: SyntaxKind) -> bool {
7050 match kind {
7051 SELF_PARAM => true,
7052 _ => false,
7053 }
7054 }
7055 fn cast(syntax: SyntaxNode) -> Option<Self> {
7056 if Self::can_cast(syntax.kind()) {
7057 Some(Self { syntax })
7058 } else {
7059 None
7060 }
7061 }
7062 fn syntax(&self) -> &SyntaxNode {
7063 &self.syntax
7064 }
7065}
7066impl ast::TypeAscriptionOwner for SelfParam {}
7067impl ast::AttrsOwner for SelfParam {}
7068impl SelfParam {
7069 pub fn amp(&self) -> Option<Amp> {
7070 support::token(&self.syntax)
7071 }
7072 pub fn lifetime(&self) -> Option<Lifetime> {
7073 support::token(&self.syntax)
7074 }
7075 pub fn self_kw(&self) -> Option<SelfKw> {
7076 support::token(&self.syntax)
7077 }
7078}
7079#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7080pub struct Param {
7081 pub(crate) syntax: SyntaxNode,
7082}
7083impl std::fmt::Display for Param {
7084 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7085 std::fmt::Display::fmt(self.syntax(), f)
7086 }
7087}
7088impl AstNode for Param {
7089 fn can_cast(kind: SyntaxKind) -> bool {
7090 match kind {
7091 PARAM => true,
7092 _ => false,
7093 }
7094 }
7095 fn cast(syntax: SyntaxNode) -> Option<Self> {
7096 if Self::can_cast(syntax.kind()) {
7097 Some(Self { syntax })
7098 } else {
7099 None
7100 }
7101 }
7102 fn syntax(&self) -> &SyntaxNode {
7103 &self.syntax
7104 }
7105}
7106impl ast::TypeAscriptionOwner for Param {}
7107impl ast::AttrsOwner for Param {}
7108impl Param {
7109 pub fn pat(&self) -> Option<Pat> {
7110 support::child(&self.syntax)
7111 }
7112 pub fn dotdotdot(&self) -> Option<Dotdotdot> {
7113 support::token(&self.syntax)
7114 }
7115}
7116#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7117pub struct UseItem {
7118 pub(crate) syntax: SyntaxNode,
7119}
7120impl std::fmt::Display for UseItem {
7121 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7122 std::fmt::Display::fmt(self.syntax(), f)
7123 }
7124}
7125impl AstNode for UseItem {
7126 fn can_cast(kind: SyntaxKind) -> bool {
7127 match kind {
7128 USE_ITEM => true,
7129 _ => false,
7130 }
7131 }
7132 fn cast(syntax: SyntaxNode) -> Option<Self> {
7133 if Self::can_cast(syntax.kind()) {
7134 Some(Self { syntax })
7135 } else {
7136 None
7137 }
7138 }
7139 fn syntax(&self) -> &SyntaxNode {
7140 &self.syntax
7141 }
7142}
7143impl ast::AttrsOwner for UseItem {}
7144impl ast::VisibilityOwner for UseItem {}
7145impl UseItem {
7146 pub fn use_kw(&self) -> Option<UseKw> {
7147 support::token(&self.syntax)
7148 }
7149 pub fn use_tree(&self) -> Option<UseTree> {
7150 support::child(&self.syntax)
7151 }
7152}
7153#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7154pub struct UseTree {
7155 pub(crate) syntax: SyntaxNode,
7156}
7157impl std::fmt::Display for UseTree {
7158 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7159 std::fmt::Display::fmt(self.syntax(), f)
7160 }
7161}
7162impl AstNode for UseTree {
7163 fn can_cast(kind: SyntaxKind) -> bool {
7164 match kind {
7165 USE_TREE => true,
7166 _ => false,
7167 }
7168 }
7169 fn cast(syntax: SyntaxNode) -> Option<Self> {
7170 if Self::can_cast(syntax.kind()) {
7171 Some(Self { syntax })
7172 } else {
7173 None
7174 }
7175 }
7176 fn syntax(&self) -> &SyntaxNode {
7177 &self.syntax
7178 }
7179}
7180impl UseTree {
7181 pub fn path(&self) -> Option<Path> {
7182 support::child(&self.syntax)
7183 }
7184 pub fn star(&self) -> Option<Star> {
7185 support::token(&self.syntax)
7186 }
7187 pub fn use_tree_list(&self) -> Option<UseTreeList> {
7188 support::child(&self.syntax)
7189 }
7190 pub fn alias(&self) -> Option<Alias> {
7191 support::child(&self.syntax)
7192 }
7193}
7194#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7195pub struct Alias {
7196 pub(crate) syntax: SyntaxNode,
7197}
7198impl std::fmt::Display for Alias {
7199 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7200 std::fmt::Display::fmt(self.syntax(), f)
7201 }
7202}
7203impl AstNode for Alias {
7204 fn can_cast(kind: SyntaxKind) -> bool {
7205 match kind {
7206 ALIAS => true,
7207 _ => false,
7208 }
7209 }
7210 fn cast(syntax: SyntaxNode) -> Option<Self> {
7211 if Self::can_cast(syntax.kind()) {
7212 Some(Self { syntax })
7213 } else {
7214 None
7215 }
7216 }
7217 fn syntax(&self) -> &SyntaxNode {
7218 &self.syntax
7219 }
7220}
7221impl ast::NameOwner for Alias {}
7222impl Alias {
7223 pub fn as_kw(&self) -> Option<AsKw> {
7224 support::token(&self.syntax)
7225 }
7226}
7227#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7228pub struct UseTreeList {
7229 pub(crate) syntax: SyntaxNode,
7230}
7231impl std::fmt::Display for UseTreeList {
7232 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7233 std::fmt::Display::fmt(self.syntax(), f)
7234 }
7235}
7236impl AstNode for UseTreeList {
7237 fn can_cast(kind: SyntaxKind) -> bool {
7238 match kind {
7239 USE_TREE_LIST => true,
7240 _ => false,
7241 }
7242 }
7243 fn cast(syntax: SyntaxNode) -> Option<Self> {
7244 if Self::can_cast(syntax.kind()) {
7245 Some(Self { syntax })
7246 } else {
7247 None
7248 }
7249 }
7250 fn syntax(&self) -> &SyntaxNode {
7251 &self.syntax
7252 }
7253}
7254impl UseTreeList {
7255 pub fn l_curly(&self) -> Option<LCurly> {
7256 support::token(&self.syntax)
7257 }
7258 pub fn use_trees(&self) -> AstChildren<UseTree> {
7259 support::children(&self.syntax)
7260 }
7261 pub fn r_curly(&self) -> Option<RCurly> {
7262 support::token(&self.syntax)
7263 }
7264}
7265#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7266pub struct ExternCrateItem {
7267 pub(crate) syntax: SyntaxNode,
7268}
7269impl std::fmt::Display for ExternCrateItem {
7270 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7271 std::fmt::Display::fmt(self.syntax(), f)
7272 }
7273}
7274impl AstNode for ExternCrateItem {
7275 fn can_cast(kind: SyntaxKind) -> bool {
7276 match kind {
7277 EXTERN_CRATE_ITEM => true,
7278 _ => false,
7279 }
7280 }
7281 fn cast(syntax: SyntaxNode) -> Option<Self> {
7282 if Self::can_cast(syntax.kind()) {
7283 Some(Self { syntax })
7284 } else {
7285 None
7286 }
7287 }
7288 fn syntax(&self) -> &SyntaxNode {
7289 &self.syntax
7290 }
7291}
7292impl ast::AttrsOwner for ExternCrateItem {}
7293impl ast::VisibilityOwner for ExternCrateItem {}
7294impl ExternCrateItem {
7295 pub fn extern_kw(&self) -> Option<ExternKw> {
7296 support::token(&self.syntax)
7297 }
7298 pub fn crate_kw(&self) -> Option<CrateKw> {
7299 support::token(&self.syntax)
7300 }
7301 pub fn name_ref(&self) -> Option<NameRef> {
7302 support::child(&self.syntax)
7303 }
7304 pub fn alias(&self) -> Option<Alias> {
7305 support::child(&self.syntax)
7306 }
7307}
7308#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7309pub struct ArgList {
7310 pub(crate) syntax: SyntaxNode,
7311}
7312impl std::fmt::Display for ArgList {
7313 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7314 std::fmt::Display::fmt(self.syntax(), f)
7315 }
7316}
7317impl AstNode for ArgList {
7318 fn can_cast(kind: SyntaxKind) -> bool {
7319 match kind {
7320 ARG_LIST => true,
7321 _ => false,
7322 }
7323 }
7324 fn cast(syntax: SyntaxNode) -> Option<Self> {
7325 if Self::can_cast(syntax.kind()) {
7326 Some(Self { syntax })
7327 } else {
7328 None
7329 }
7330 }
7331 fn syntax(&self) -> &SyntaxNode {
7332 &self.syntax
7333 }
7334}
7335impl ArgList {
7336 pub fn l_paren(&self) -> Option<LParen> {
7337 support::token(&self.syntax)
7338 }
7339 pub fn args(&self) -> AstChildren<Expr> {
7340 support::children(&self.syntax)
7341 }
7342 pub fn r_paren(&self) -> Option<RParen> {
7343 support::token(&self.syntax)
7344 }
7345}
7346#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7347pub struct Path {
7348 pub(crate) syntax: SyntaxNode,
7349}
7350impl std::fmt::Display for Path {
7351 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7352 std::fmt::Display::fmt(self.syntax(), f)
7353 }
7354}
7355impl AstNode for Path {
7356 fn can_cast(kind: SyntaxKind) -> bool {
7357 match kind {
7358 PATH => true,
7359 _ => false,
7360 }
7361 }
7362 fn cast(syntax: SyntaxNode) -> Option<Self> {
7363 if Self::can_cast(syntax.kind()) {
7364 Some(Self { syntax })
7365 } else {
7366 None
7367 }
7368 }
7369 fn syntax(&self) -> &SyntaxNode {
7370 &self.syntax
7371 }
7372}
7373impl Path {
7374 pub fn segment(&self) -> Option<PathSegment> {
7375 support::child(&self.syntax)
7376 }
7377 pub fn qualifier(&self) -> Option<Path> {
7378 support::child(&self.syntax)
7379 }
7380}
7381#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7382pub struct PathSegment {
7383 pub(crate) syntax: SyntaxNode,
7384}
7385impl std::fmt::Display for PathSegment {
7386 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7387 std::fmt::Display::fmt(self.syntax(), f)
7388 }
7389}
7390impl AstNode for PathSegment {
7391 fn can_cast(kind: SyntaxKind) -> bool {
7392 match kind {
7393 PATH_SEGMENT => true,
7394 _ => false,
7395 }
7396 }
7397 fn cast(syntax: SyntaxNode) -> Option<Self> {
7398 if Self::can_cast(syntax.kind()) {
7399 Some(Self { syntax })
7400 } else {
7401 None
7402 }
7403 }
7404 fn syntax(&self) -> &SyntaxNode {
7405 &self.syntax
7406 }
7407}
7408impl PathSegment {
7409 pub fn coloncolon(&self) -> Option<Coloncolon> {
7410 support::token(&self.syntax)
7411 }
7412 pub fn l_angle(&self) -> Option<LAngle> {
7413 support::token(&self.syntax)
7414 }
7415 pub fn name_ref(&self) -> Option<NameRef> {
7416 support::child(&self.syntax)
7417 }
7418 pub fn type_arg_list(&self) -> Option<TypeArgList> {
7419 support::child(&self.syntax)
7420 }
7421 pub fn param_list(&self) -> Option<ParamList> {
7422 support::child(&self.syntax)
7423 }
7424 pub fn ret_type(&self) -> Option<RetType> {
7425 support::child(&self.syntax)
7426 }
7427 pub fn path_type(&self) -> Option<PathType> {
7428 support::child(&self.syntax)
7429 }
7430 pub fn r_angle(&self) -> Option<RAngle> {
7431 support::token(&self.syntax)
7432 }
7433}
7434#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7435pub struct TypeArgList {
7436 pub(crate) syntax: SyntaxNode,
7437}
7438impl std::fmt::Display for TypeArgList {
7439 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7440 std::fmt::Display::fmt(self.syntax(), f)
7441 }
7442}
7443impl AstNode for TypeArgList {
7444 fn can_cast(kind: SyntaxKind) -> bool {
7445 match kind {
7446 TYPE_ARG_LIST => true,
7447 _ => false,
7448 }
7449 }
7450 fn cast(syntax: SyntaxNode) -> Option<Self> {
7451 if Self::can_cast(syntax.kind()) {
7452 Some(Self { syntax })
7453 } else {
7454 None
7455 }
7456 }
7457 fn syntax(&self) -> &SyntaxNode {
7458 &self.syntax
7459 }
7460}
7461impl TypeArgList {
7462 pub fn coloncolon(&self) -> Option<Coloncolon> {
7463 support::token(&self.syntax)
7464 }
7465 pub fn l_angle(&self) -> Option<LAngle> {
7466 support::token(&self.syntax)
7467 }
7468 pub fn generic_args(&self) -> AstChildren<GenericArg> {
7469 support::children(&self.syntax)
7470 }
7471 pub fn type_args(&self) -> AstChildren<TypeArg> {
7472 support::children(&self.syntax)
7473 }
7474 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> {
7475 support::children(&self.syntax)
7476 }
7477 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> {
7478 support::children(&self.syntax)
7479 }
7480 pub fn const_args(&self) -> AstChildren<ConstArg> {
7481 support::children(&self.syntax)
7482 }
7483 pub fn r_angle(&self) -> Option<RAngle> {
7484 support::token(&self.syntax)
7485 }
7486}
7487#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7488pub struct TypeArg {
7489 pub(crate) syntax: SyntaxNode,
7490}
7491impl std::fmt::Display for TypeArg {
7492 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7493 std::fmt::Display::fmt(self.syntax(), f)
7494 }
7495}
7496impl AstNode for TypeArg {
7497 fn can_cast(kind: SyntaxKind) -> bool {
7498 match kind {
7499 TYPE_ARG => true,
7500 _ => false,
7501 }
7502 }
7503 fn cast(syntax: SyntaxNode) -> Option<Self> {
7504 if Self::can_cast(syntax.kind()) {
7505 Some(Self { syntax })
7506 } else {
7507 None
7508 }
7509 }
7510 fn syntax(&self) -> &SyntaxNode {
7511 &self.syntax
7512 }
7513}
7514impl TypeArg {
7515 pub fn type_ref(&self) -> Option<TypeRef> {
7516 support::child(&self.syntax)
7517 }
7518}
7519#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7520pub struct AssocTypeArg {
7521 pub(crate) syntax: SyntaxNode,
7522}
7523impl std::fmt::Display for AssocTypeArg {
7524 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7525 std::fmt::Display::fmt(self.syntax(), f)
7526 }
7527}
7528impl AstNode for AssocTypeArg {
7529 fn can_cast(kind: SyntaxKind) -> bool {
7530 match kind {
7531 ASSOC_TYPE_ARG => true,
7532 _ => false,
7533 }
7534 }
7535 fn cast(syntax: SyntaxNode) -> Option<Self> {
7536 if Self::can_cast(syntax.kind()) {
7537 Some(Self { syntax })
7538 } else {
7539 None
7540 }
7541 }
7542 fn syntax(&self) -> &SyntaxNode {
7543 &self.syntax
7544 }
7545}
7546impl ast::TypeBoundsOwner for AssocTypeArg {}
7547impl AssocTypeArg {
7548 pub fn name_ref(&self) -> Option<NameRef> {
7549 support::child(&self.syntax)
7550 }
7551 pub fn eq(&self) -> Option<Eq> {
7552 support::token(&self.syntax)
7553 }
7554 pub fn type_ref(&self) -> Option<TypeRef> {
7555 support::child(&self.syntax)
7556 }
7557}
7558#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7559pub struct LifetimeArg {
7560 pub(crate) syntax: SyntaxNode,
7561}
7562impl std::fmt::Display for LifetimeArg {
7563 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7564 std::fmt::Display::fmt(self.syntax(), f)
7565 }
7566}
7567impl AstNode for LifetimeArg {
7568 fn can_cast(kind: SyntaxKind) -> bool {
7569 match kind {
7570 LIFETIME_ARG => true,
7571 _ => false,
7572 }
7573 }
7574 fn cast(syntax: SyntaxNode) -> Option<Self> {
7575 if Self::can_cast(syntax.kind()) {
7576 Some(Self { syntax })
7577 } else {
7578 None
7579 }
7580 }
7581 fn syntax(&self) -> &SyntaxNode {
7582 &self.syntax
7583 }
7584}
7585impl LifetimeArg {
7586 pub fn lifetime(&self) -> Option<Lifetime> {
7587 support::token(&self.syntax)
7588 }
7589}
7590#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7591pub struct ConstArg {
7592 pub(crate) syntax: SyntaxNode,
7593}
7594impl std::fmt::Display for ConstArg {
7595 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7596 std::fmt::Display::fmt(self.syntax(), f)
7597 }
7598}
7599impl AstNode for ConstArg {
7600 fn can_cast(kind: SyntaxKind) -> bool {
7601 match kind {
7602 CONST_ARG => true,
7603 _ => false,
7604 }
7605 }
7606 fn cast(syntax: SyntaxNode) -> Option<Self> {
7607 if Self::can_cast(syntax.kind()) {
7608 Some(Self { syntax })
7609 } else {
7610 None
7611 }
7612 }
7613 fn syntax(&self) -> &SyntaxNode {
7614 &self.syntax
7615 }
7616}
7617impl ConstArg {
7618 pub fn literal(&self) -> Option<Literal> {
7619 support::child(&self.syntax)
7620 }
7621 pub fn eq(&self) -> Option<Eq> {
7622 support::token(&self.syntax)
7623 }
7624 pub fn block_expr(&self) -> Option<BlockExpr> {
7625 support::child(&self.syntax)
7626 }
7627}
7628#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7629pub struct MacroItems {
7630 pub(crate) syntax: SyntaxNode,
7631}
7632impl std::fmt::Display for MacroItems {
7633 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7634 std::fmt::Display::fmt(self.syntax(), f)
7635 }
7636}
7637impl AstNode for MacroItems {
7638 fn can_cast(kind: SyntaxKind) -> bool {
7639 match kind {
7640 MACRO_ITEMS => true,
7641 _ => false,
7642 }
7643 }
7644 fn cast(syntax: SyntaxNode) -> Option<Self> {
7645 if Self::can_cast(syntax.kind()) {
7646 Some(Self { syntax })
7647 } else {
7648 None
7649 }
7650 }
7651 fn syntax(&self) -> &SyntaxNode {
7652 &self.syntax
7653 }
7654}
7655impl ast::ModuleItemOwner for MacroItems {}
7656impl ast::FnDefOwner for MacroItems {}
7657impl MacroItems {}
7658#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7659pub struct MacroStmts {
7660 pub(crate) syntax: SyntaxNode,
7661}
7662impl std::fmt::Display for MacroStmts {
7663 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7664 std::fmt::Display::fmt(self.syntax(), f)
7665 }
7666}
7667impl AstNode for MacroStmts {
7668 fn can_cast(kind: SyntaxKind) -> bool {
7669 match kind {
7670 MACRO_STMTS => true,
7671 _ => false,
7672 }
7673 }
7674 fn cast(syntax: SyntaxNode) -> Option<Self> {
7675 if Self::can_cast(syntax.kind()) {
7676 Some(Self { syntax })
7677 } else {
7678 None
7679 }
7680 }
7681 fn syntax(&self) -> &SyntaxNode {
7682 &self.syntax
7683 }
7684}
7685impl MacroStmts {
7686 pub fn statements(&self) -> AstChildren<Stmt> {
7687 support::children(&self.syntax)
7688 }
7689 pub fn expr(&self) -> Option<Expr> {
7690 support::child(&self.syntax)
7691 }
7692}
7693#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7694pub struct ExternItemList {
7695 pub(crate) syntax: SyntaxNode,
7696}
7697impl std::fmt::Display for ExternItemList {
7698 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7699 std::fmt::Display::fmt(self.syntax(), f)
7700 }
7701}
7702impl AstNode for ExternItemList {
7703 fn can_cast(kind: SyntaxKind) -> bool {
7704 match kind {
7705 EXTERN_ITEM_LIST => true,
7706 _ => false,
7707 }
7708 }
7709 fn cast(syntax: SyntaxNode) -> Option<Self> {
7710 if Self::can_cast(syntax.kind()) {
7711 Some(Self { syntax })
7712 } else {
7713 None
7714 }
7715 }
7716 fn syntax(&self) -> &SyntaxNode {
7717 &self.syntax
7718 }
7719}
7720impl ast::FnDefOwner for ExternItemList {}
7721impl ast::ModuleItemOwner for ExternItemList {}
7722impl ExternItemList {
7723 pub fn l_curly(&self) -> Option<LCurly> {
7724 support::token(&self.syntax)
7725 }
7726 pub fn extern_items(&self) -> AstChildren<ExternItem> {
7727 support::children(&self.syntax)
7728 }
7729 pub fn r_curly(&self) -> Option<RCurly> {
7730 support::token(&self.syntax)
7731 }
7732}
7733#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7734pub struct ExternBlock {
7735 pub(crate) syntax: SyntaxNode,
7736}
7737impl std::fmt::Display for ExternBlock {
7738 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7739 std::fmt::Display::fmt(self.syntax(), f)
7740 }
7741}
7742impl AstNode for ExternBlock {
7743 fn can_cast(kind: SyntaxKind) -> bool {
7744 match kind {
7745 EXTERN_BLOCK => true,
7746 _ => false,
7747 }
7748 }
7749 fn cast(syntax: SyntaxNode) -> Option<Self> {
7750 if Self::can_cast(syntax.kind()) {
7751 Some(Self { syntax })
7752 } else {
7753 None
7754 }
7755 }
7756 fn syntax(&self) -> &SyntaxNode {
7757 &self.syntax
7758 }
7759}
7760impl ExternBlock {
7761 pub fn abi(&self) -> Option<Abi> {
7762 support::child(&self.syntax)
7763 }
7764 pub fn extern_item_list(&self) -> Option<ExternItemList> {
7765 support::child(&self.syntax)
7766 }
7767}
7768#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7769pub struct MetaItem {
7770 pub(crate) syntax: SyntaxNode,
7771}
7772impl std::fmt::Display for MetaItem {
7773 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7774 std::fmt::Display::fmt(self.syntax(), f)
7775 }
7776}
7777impl AstNode for MetaItem {
7778 fn can_cast(kind: SyntaxKind) -> bool {
7779 match kind {
7780 META_ITEM => true,
7781 _ => false,
7782 }
7783 }
7784 fn cast(syntax: SyntaxNode) -> Option<Self> {
7785 if Self::can_cast(syntax.kind()) {
7786 Some(Self { syntax })
7787 } else {
7788 None
7789 }
7790 }
7791 fn syntax(&self) -> &SyntaxNode {
7792 &self.syntax
7793 }
7794}
7795impl MetaItem {
7796 pub fn path(&self) -> Option<Path> {
7797 support::child(&self.syntax)
7798 }
7799 pub fn eq(&self) -> Option<Eq> {
7800 support::token(&self.syntax)
7801 }
7802 pub fn attr_input(&self) -> Option<AttrInput> {
7803 support::child(&self.syntax)
7804 }
7805 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> {
7806 support::children(&self.syntax)
7807 }
7808}
7809#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7810pub struct MacroDef {
7811 pub(crate) syntax: SyntaxNode,
7812}
7813impl std::fmt::Display for MacroDef {
7814 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7815 std::fmt::Display::fmt(self.syntax(), f)
7816 }
7817}
7818impl AstNode for MacroDef {
7819 fn can_cast(kind: SyntaxKind) -> bool {
7820 match kind {
7821 MACRO_DEF => true,
7822 _ => false,
7823 }
7824 }
7825 fn cast(syntax: SyntaxNode) -> Option<Self> {
7826 if Self::can_cast(syntax.kind()) {
7827 Some(Self { syntax })
7828 } else {
7829 None
7830 }
7831 }
7832 fn syntax(&self) -> &SyntaxNode {
7833 &self.syntax
7834 }
7835}
7836impl MacroDef {
7837 pub fn name(&self) -> Option<Name> {
7838 support::child(&self.syntax)
7839 }
7840 pub fn token_tree(&self) -> Option<TokenTree> {
7841 support::child(&self.syntax)
7842 }
7843}
7844#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7845pub enum NominalDef {
7846 StructDef(StructDef),
7847 EnumDef(EnumDef),
7848 UnionDef(UnionDef),
7849}
7850impl From<StructDef> for NominalDef {
7851 fn from(node: StructDef) -> NominalDef {
7852 NominalDef::StructDef(node)
7853 }
7854}
7855impl From<EnumDef> for NominalDef {
7856 fn from(node: EnumDef) -> NominalDef {
7857 NominalDef::EnumDef(node)
7858 }
7859}
7860impl From<UnionDef> for NominalDef {
7861 fn from(node: UnionDef) -> NominalDef {
7862 NominalDef::UnionDef(node)
7863 }
7864}
7865impl std::fmt::Display for NominalDef {
7866 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7867 std::fmt::Display::fmt(self.syntax(), f)
7868 }
7869}
7870impl AstNode for NominalDef {
7871 fn can_cast(kind: SyntaxKind) -> bool {
7872 match kind {
7873 STRUCT_DEF | ENUM_DEF | UNION_DEF => true,
7874 _ => false,
7875 }
7876 }
7877 fn cast(syntax: SyntaxNode) -> Option<Self> {
7878 let res = match syntax.kind() {
7879 STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
7880 ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
7881 UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }),
7882 _ => return None,
7883 };
7884 Some(res)
7885 }
7886 fn syntax(&self) -> &SyntaxNode {
7887 match self {
7888 NominalDef::StructDef(it) => &it.syntax,
7889 NominalDef::EnumDef(it) => &it.syntax,
7890 NominalDef::UnionDef(it) => &it.syntax,
7891 }
7892 }
7893}
7894impl ast::NameOwner for NominalDef {}
7895impl ast::TypeParamsOwner for NominalDef {}
7896impl ast::AttrsOwner for NominalDef {}
7897#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7898pub enum GenericParam {
7899 LifetimeParam(LifetimeParam),
7900 TypeParam(TypeParam),
7901 ConstParam(ConstParam),
7902}
7903impl From<LifetimeParam> for GenericParam {
7904 fn from(node: LifetimeParam) -> GenericParam {
7905 GenericParam::LifetimeParam(node)
7906 }
7907}
7908impl From<TypeParam> for GenericParam {
7909 fn from(node: TypeParam) -> GenericParam {
7910 GenericParam::TypeParam(node)
7911 }
7912}
7913impl From<ConstParam> for GenericParam {
7914 fn from(node: ConstParam) -> GenericParam {
7915 GenericParam::ConstParam(node)
7916 }
7917}
7918impl std::fmt::Display for GenericParam {
7919 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7920 std::fmt::Display::fmt(self.syntax(), f)
7921 }
7922}
7923impl AstNode for GenericParam {
7924 fn can_cast(kind: SyntaxKind) -> bool {
7925 match kind {
7926 LIFETIME_PARAM | TYPE_PARAM | CONST_PARAM => true,
7927 _ => false,
7928 }
7929 }
7930 fn cast(syntax: SyntaxNode) -> Option<Self> {
7931 let res = match syntax.kind() {
7932 LIFETIME_PARAM => GenericParam::LifetimeParam(LifetimeParam { syntax }),
7933 TYPE_PARAM => GenericParam::TypeParam(TypeParam { syntax }),
7934 CONST_PARAM => GenericParam::ConstParam(ConstParam { syntax }),
7935 _ => return None,
7936 };
7937 Some(res)
7938 }
7939 fn syntax(&self) -> &SyntaxNode {
7940 match self {
7941 GenericParam::LifetimeParam(it) => &it.syntax,
7942 GenericParam::TypeParam(it) => &it.syntax,
7943 GenericParam::ConstParam(it) => &it.syntax,
7944 }
7945 }
7946}
7947#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7948pub enum GenericArg {
7949 LifetimeArg(LifetimeArg),
7950 TypeArg(TypeArg),
7951 ConstArg(ConstArg),
7952 AssocTypeArg(AssocTypeArg),
7953}
7954impl From<LifetimeArg> for GenericArg {
7955 fn from(node: LifetimeArg) -> GenericArg {
7956 GenericArg::LifetimeArg(node)
7957 }
7958}
7959impl From<TypeArg> for GenericArg {
7960 fn from(node: TypeArg) -> GenericArg {
7961 GenericArg::TypeArg(node)
7962 }
7963}
7964impl From<ConstArg> for GenericArg {
7965 fn from(node: ConstArg) -> GenericArg {
7966 GenericArg::ConstArg(node)
7967 }
7968}
7969impl From<AssocTypeArg> for GenericArg {
7970 fn from(node: AssocTypeArg) -> GenericArg {
7971 GenericArg::AssocTypeArg(node)
7972 }
7973}
7974impl std::fmt::Display for GenericArg {
7975 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7976 std::fmt::Display::fmt(self.syntax(), f)
7977 }
7978}
7979impl AstNode for GenericArg {
7980 fn can_cast(kind: SyntaxKind) -> bool {
7981 match kind {
7982 LIFETIME_ARG | TYPE_ARG | CONST_ARG | ASSOC_TYPE_ARG => true,
7983 _ => false,
7984 }
7985 }
7986 fn cast(syntax: SyntaxNode) -> Option<Self> {
7987 let res = match syntax.kind() {
7988 LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }),
7989 TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }),
7990 CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }),
7991 ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }),
7992 _ => return None,
7993 };
7994 Some(res)
7995 }
7996 fn syntax(&self) -> &SyntaxNode {
7997 match self {
7998 GenericArg::LifetimeArg(it) => &it.syntax,
7999 GenericArg::TypeArg(it) => &it.syntax,
8000 GenericArg::ConstArg(it) => &it.syntax,
8001 GenericArg::AssocTypeArg(it) => &it.syntax,
8002 }
8003 }
8004}
8005#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8006pub enum TypeRef {
8007 ParenType(ParenType),
8008 TupleType(TupleType),
8009 NeverType(NeverType),
8010 PathType(PathType),
8011 PointerType(PointerType),
8012 ArrayType(ArrayType),
8013 SliceType(SliceType),
8014 ReferenceType(ReferenceType),
8015 PlaceholderType(PlaceholderType),
8016 FnPointerType(FnPointerType),
8017 ForType(ForType),
8018 ImplTraitType(ImplTraitType),
8019 DynTraitType(DynTraitType),
8020}
8021impl From<ParenType> for TypeRef {
8022 fn from(node: ParenType) -> TypeRef {
8023 TypeRef::ParenType(node)
8024 }
8025}
8026impl From<TupleType> for TypeRef {
8027 fn from(node: TupleType) -> TypeRef {
8028 TypeRef::TupleType(node)
8029 }
8030}
8031impl From<NeverType> for TypeRef {
8032 fn from(node: NeverType) -> TypeRef {
8033 TypeRef::NeverType(node)
8034 }
8035}
8036impl From<PathType> for TypeRef {
8037 fn from(node: PathType) -> TypeRef {
8038 TypeRef::PathType(node)
8039 }
8040}
8041impl From<PointerType> for TypeRef {
8042 fn from(node: PointerType) -> TypeRef {
8043 TypeRef::PointerType(node)
8044 }
8045}
8046impl From<ArrayType> for TypeRef {
8047 fn from(node: ArrayType) -> TypeRef {
8048 TypeRef::ArrayType(node)
8049 }
8050}
8051impl From<SliceType> for TypeRef {
8052 fn from(node: SliceType) -> TypeRef {
8053 TypeRef::SliceType(node)
8054 }
8055}
8056impl From<ReferenceType> for TypeRef {
8057 fn from(node: ReferenceType) -> TypeRef {
8058 TypeRef::ReferenceType(node)
8059 }
8060}
8061impl From<PlaceholderType> for TypeRef {
8062 fn from(node: PlaceholderType) -> TypeRef {
8063 TypeRef::PlaceholderType(node)
8064 }
8065}
8066impl From<FnPointerType> for TypeRef {
8067 fn from(node: FnPointerType) -> TypeRef {
8068 TypeRef::FnPointerType(node)
8069 }
8070}
8071impl From<ForType> for TypeRef {
8072 fn from(node: ForType) -> TypeRef {
8073 TypeRef::ForType(node)
8074 }
8075}
8076impl From<ImplTraitType> for TypeRef {
8077 fn from(node: ImplTraitType) -> TypeRef {
8078 TypeRef::ImplTraitType(node)
8079 }
8080}
8081impl From<DynTraitType> for TypeRef {
8082 fn from(node: DynTraitType) -> TypeRef {
8083 TypeRef::DynTraitType(node)
8084 }
8085}
8086impl std::fmt::Display for TypeRef {
8087 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8088 std::fmt::Display::fmt(self.syntax(), f)
8089 }
8090}
8091impl AstNode for TypeRef {
8092 fn can_cast(kind: SyntaxKind) -> bool {
8093 match kind {
8094 PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
8095 | SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
8096 | IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
8097 _ => false,
8098 }
8099 }
8100 fn cast(syntax: SyntaxNode) -> Option<Self> {
8101 let res = match syntax.kind() {
8102 PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }),
8103 TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }),
8104 NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }),
8105 PATH_TYPE => TypeRef::PathType(PathType { syntax }),
8106 POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }),
8107 ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }),
8108 SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }),
8109 REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }),
8110 PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }),
8111 FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }),
8112 FOR_TYPE => TypeRef::ForType(ForType { syntax }),
8113 IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }),
8114 DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }),
8115 _ => return None,
8116 };
8117 Some(res)
8118 }
8119 fn syntax(&self) -> &SyntaxNode {
8120 match self {
8121 TypeRef::ParenType(it) => &it.syntax,
8122 TypeRef::TupleType(it) => &it.syntax,
8123 TypeRef::NeverType(it) => &it.syntax,
8124 TypeRef::PathType(it) => &it.syntax,
8125 TypeRef::PointerType(it) => &it.syntax,
8126 TypeRef::ArrayType(it) => &it.syntax,
8127 TypeRef::SliceType(it) => &it.syntax,
8128 TypeRef::ReferenceType(it) => &it.syntax,
8129 TypeRef::PlaceholderType(it) => &it.syntax,
8130 TypeRef::FnPointerType(it) => &it.syntax,
8131 TypeRef::ForType(it) => &it.syntax,
8132 TypeRef::ImplTraitType(it) => &it.syntax,
8133 TypeRef::DynTraitType(it) => &it.syntax,
8134 }
8135 }
8136}
8137#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8138pub enum ModuleItem {
8139 StructDef(StructDef),
8140 UnionDef(UnionDef),
8141 EnumDef(EnumDef),
8142 FnDef(FnDef),
8143 TraitDef(TraitDef),
8144 TypeAliasDef(TypeAliasDef),
8145 ImplDef(ImplDef),
8146 UseItem(UseItem),
8147 ExternCrateItem(ExternCrateItem),
8148 ConstDef(ConstDef),
8149 StaticDef(StaticDef),
8150 Module(Module),
8151 MacroCall(MacroCall),
8152 ExternBlock(ExternBlock),
8153}
8154impl From<StructDef> for ModuleItem {
8155 fn from(node: StructDef) -> ModuleItem {
8156 ModuleItem::StructDef(node)
8157 }
8158}
8159impl From<UnionDef> for ModuleItem {
8160 fn from(node: UnionDef) -> ModuleItem {
8161 ModuleItem::UnionDef(node)
8162 }
8163}
8164impl From<EnumDef> for ModuleItem {
8165 fn from(node: EnumDef) -> ModuleItem {
8166 ModuleItem::EnumDef(node)
8167 }
8168}
8169impl From<FnDef> for ModuleItem {
8170 fn from(node: FnDef) -> ModuleItem {
8171 ModuleItem::FnDef(node)
8172 }
8173}
8174impl From<TraitDef> for ModuleItem {
8175 fn from(node: TraitDef) -> ModuleItem {
8176 ModuleItem::TraitDef(node)
8177 }
8178}
8179impl From<TypeAliasDef> for ModuleItem {
8180 fn from(node: TypeAliasDef) -> ModuleItem {
8181 ModuleItem::TypeAliasDef(node)
8182 }
8183}
8184impl From<ImplDef> for ModuleItem {
8185 fn from(node: ImplDef) -> ModuleItem {
8186 ModuleItem::ImplDef(node)
8187 }
8188}
8189impl From<UseItem> for ModuleItem {
8190 fn from(node: UseItem) -> ModuleItem {
8191 ModuleItem::UseItem(node)
8192 }
8193}
8194impl From<ExternCrateItem> for ModuleItem {
8195 fn from(node: ExternCrateItem) -> ModuleItem {
8196 ModuleItem::ExternCrateItem(node)
8197 }
8198}
8199impl From<ConstDef> for ModuleItem {
8200 fn from(node: ConstDef) -> ModuleItem {
8201 ModuleItem::ConstDef(node)
8202 }
8203}
8204impl From<StaticDef> for ModuleItem {
8205 fn from(node: StaticDef) -> ModuleItem {
8206 ModuleItem::StaticDef(node)
8207 }
8208}
8209impl From<Module> for ModuleItem {
8210 fn from(node: Module) -> ModuleItem {
8211 ModuleItem::Module(node)
8212 }
8213}
8214impl From<MacroCall> for ModuleItem {
8215 fn from(node: MacroCall) -> ModuleItem {
8216 ModuleItem::MacroCall(node)
8217 }
8218}
8219impl From<ExternBlock> for ModuleItem {
8220 fn from(node: ExternBlock) -> ModuleItem {
8221 ModuleItem::ExternBlock(node)
8222 }
8223}
8224impl std::fmt::Display for ModuleItem {
8225 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8226 std::fmt::Display::fmt(self.syntax(), f)
8227 }
8228}
8229impl AstNode for ModuleItem {
8230 fn can_cast(kind: SyntaxKind) -> bool {
8231 match kind {
8232 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF
8233 | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL
8234 | EXTERN_BLOCK => true,
8235 _ => false,
8236 }
8237 }
8238 fn cast(syntax: SyntaxNode) -> Option<Self> {
8239 let res = match syntax.kind() {
8240 STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
8241 UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }),
8242 ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
8243 FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
8244 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
8245 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
8246 IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }),
8247 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
8248 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
8249 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
8250 STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
8251 MODULE => ModuleItem::Module(Module { syntax }),
8252 MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }),
8253 EXTERN_BLOCK => ModuleItem::ExternBlock(ExternBlock { syntax }),
8254 _ => return None,
8255 };
8256 Some(res)
8257 }
8258 fn syntax(&self) -> &SyntaxNode {
8259 match self {
8260 ModuleItem::StructDef(it) => &it.syntax,
8261 ModuleItem::UnionDef(it) => &it.syntax,
8262 ModuleItem::EnumDef(it) => &it.syntax,
8263 ModuleItem::FnDef(it) => &it.syntax,
8264 ModuleItem::TraitDef(it) => &it.syntax,
8265 ModuleItem::TypeAliasDef(it) => &it.syntax,
8266 ModuleItem::ImplDef(it) => &it.syntax,
8267 ModuleItem::UseItem(it) => &it.syntax,
8268 ModuleItem::ExternCrateItem(it) => &it.syntax,
8269 ModuleItem::ConstDef(it) => &it.syntax,
8270 ModuleItem::StaticDef(it) => &it.syntax,
8271 ModuleItem::Module(it) => &it.syntax,
8272 ModuleItem::MacroCall(it) => &it.syntax,
8273 ModuleItem::ExternBlock(it) => &it.syntax,
8274 }
8275 }
8276}
8277impl ast::NameOwner for ModuleItem {}
8278impl ast::AttrsOwner for ModuleItem {}
8279impl ast::VisibilityOwner for ModuleItem {}
8280#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8281pub enum ImplItem {
8282 FnDef(FnDef),
8283 TypeAliasDef(TypeAliasDef),
8284 ConstDef(ConstDef),
8285}
8286impl From<FnDef> for ImplItem {
8287 fn from(node: FnDef) -> ImplItem {
8288 ImplItem::FnDef(node)
8289 }
8290}
8291impl From<TypeAliasDef> for ImplItem {
8292 fn from(node: TypeAliasDef) -> ImplItem {
8293 ImplItem::TypeAliasDef(node)
8294 }
8295}
8296impl From<ConstDef> for ImplItem {
8297 fn from(node: ConstDef) -> ImplItem {
8298 ImplItem::ConstDef(node)
8299 }
8300}
8301impl std::fmt::Display for ImplItem {
8302 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8303 std::fmt::Display::fmt(self.syntax(), f)
8304 }
8305}
8306impl AstNode for ImplItem {
8307 fn can_cast(kind: SyntaxKind) -> bool {
8308 match kind {
8309 FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true,
8310 _ => false,
8311 }
8312 }
8313 fn cast(syntax: SyntaxNode) -> Option<Self> {
8314 let res = match syntax.kind() {
8315 FN_DEF => ImplItem::FnDef(FnDef { syntax }),
8316 TYPE_ALIAS_DEF => ImplItem::TypeAliasDef(TypeAliasDef { syntax }),
8317 CONST_DEF => ImplItem::ConstDef(ConstDef { syntax }),
8318 _ => return None,
8319 };
8320 Some(res)
8321 }
8322 fn syntax(&self) -> &SyntaxNode {
8323 match self {
8324 ImplItem::FnDef(it) => &it.syntax,
8325 ImplItem::TypeAliasDef(it) => &it.syntax,
8326 ImplItem::ConstDef(it) => &it.syntax,
8327 }
8328 }
8329}
8330impl ast::NameOwner for ImplItem {}
8331impl ast::AttrsOwner for ImplItem {}
8332#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8333pub enum ExternItem {
8334 FnDef(FnDef),
8335 StaticDef(StaticDef),
8336}
8337impl From<FnDef> for ExternItem {
8338 fn from(node: FnDef) -> ExternItem {
8339 ExternItem::FnDef(node)
8340 }
8341}
8342impl From<StaticDef> for ExternItem {
8343 fn from(node: StaticDef) -> ExternItem {
8344 ExternItem::StaticDef(node)
8345 }
8346}
8347impl std::fmt::Display for ExternItem {
8348 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8349 std::fmt::Display::fmt(self.syntax(), f)
8350 }
8351}
8352impl AstNode for ExternItem {
8353 fn can_cast(kind: SyntaxKind) -> bool {
8354 match kind {
8355 FN_DEF | STATIC_DEF => true,
8356 _ => false,
8357 }
8358 }
8359 fn cast(syntax: SyntaxNode) -> Option<Self> {
8360 let res = match syntax.kind() {
8361 FN_DEF => ExternItem::FnDef(FnDef { syntax }),
8362 STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }),
8363 _ => return None,
8364 };
8365 Some(res)
8366 }
8367 fn syntax(&self) -> &SyntaxNode {
8368 match self {
8369 ExternItem::FnDef(it) => &it.syntax,
8370 ExternItem::StaticDef(it) => &it.syntax,
8371 }
8372 }
8373}
8374impl ast::NameOwner for ExternItem {}
8375impl ast::AttrsOwner for ExternItem {}
8376impl ast::VisibilityOwner for ExternItem {}
8377#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8378pub enum Expr {
8379 TupleExpr(TupleExpr),
8380 ArrayExpr(ArrayExpr),
8381 ParenExpr(ParenExpr),
8382 PathExpr(PathExpr),
8383 LambdaExpr(LambdaExpr),
8384 IfExpr(IfExpr),
8385 LoopExpr(LoopExpr),
8386 ForExpr(ForExpr),
8387 WhileExpr(WhileExpr),
8388 ContinueExpr(ContinueExpr),
8389 BreakExpr(BreakExpr),
8390 Label(Label),
8391 BlockExpr(BlockExpr),
8392 ReturnExpr(ReturnExpr),
8393 MatchExpr(MatchExpr),
8394 RecordLit(RecordLit),
8395 CallExpr(CallExpr),
8396 IndexExpr(IndexExpr),
8397 MethodCallExpr(MethodCallExpr),
8398 FieldExpr(FieldExpr),
8399 AwaitExpr(AwaitExpr),
8400 TryExpr(TryExpr),
8401 TryBlockExpr(TryBlockExpr),
8402 CastExpr(CastExpr),
8403 RefExpr(RefExpr),
8404 PrefixExpr(PrefixExpr),
8405 RangeExpr(RangeExpr),
8406 BinExpr(BinExpr),
8407 Literal(Literal),
8408 MacroCall(MacroCall),
8409 BoxExpr(BoxExpr),
8410}
8411impl From<TupleExpr> for Expr {
8412 fn from(node: TupleExpr) -> Expr {
8413 Expr::TupleExpr(node)
8414 }
8415}
8416impl From<ArrayExpr> for Expr {
8417 fn from(node: ArrayExpr) -> Expr {
8418 Expr::ArrayExpr(node)
8419 }
8420}
8421impl From<ParenExpr> for Expr {
8422 fn from(node: ParenExpr) -> Expr {
8423 Expr::ParenExpr(node)
8424 }
8425}
8426impl From<PathExpr> for Expr {
8427 fn from(node: PathExpr) -> Expr {
8428 Expr::PathExpr(node)
8429 }
8430}
8431impl From<LambdaExpr> for Expr {
8432 fn from(node: LambdaExpr) -> Expr {
8433 Expr::LambdaExpr(node)
8434 }
8435}
8436impl From<IfExpr> for Expr {
8437 fn from(node: IfExpr) -> Expr {
8438 Expr::IfExpr(node)
8439 }
8440}
8441impl From<LoopExpr> for Expr {
8442 fn from(node: LoopExpr) -> Expr {
8443 Expr::LoopExpr(node)
8444 }
8445}
8446impl From<ForExpr> for Expr {
8447 fn from(node: ForExpr) -> Expr {
8448 Expr::ForExpr(node)
8449 }
8450}
8451impl From<WhileExpr> for Expr {
8452 fn from(node: WhileExpr) -> Expr {
8453 Expr::WhileExpr(node)
8454 }
8455}
8456impl From<ContinueExpr> for Expr {
8457 fn from(node: ContinueExpr) -> Expr {
8458 Expr::ContinueExpr(node)
8459 }
8460}
8461impl From<BreakExpr> for Expr {
8462 fn from(node: BreakExpr) -> Expr {
8463 Expr::BreakExpr(node)
8464 }
8465}
8466impl From<Label> for Expr {
8467 fn from(node: Label) -> Expr {
8468 Expr::Label(node)
8469 }
8470}
8471impl From<BlockExpr> for Expr {
8472 fn from(node: BlockExpr) -> Expr {
8473 Expr::BlockExpr(node)
8474 }
8475}
8476impl From<ReturnExpr> for Expr {
8477 fn from(node: ReturnExpr) -> Expr {
8478 Expr::ReturnExpr(node)
8479 }
8480}
8481impl From<MatchExpr> for Expr {
8482 fn from(node: MatchExpr) -> Expr {
8483 Expr::MatchExpr(node)
8484 }
8485}
8486impl From<RecordLit> for Expr {
8487 fn from(node: RecordLit) -> Expr {
8488 Expr::RecordLit(node)
8489 }
8490}
8491impl From<CallExpr> for Expr {
8492 fn from(node: CallExpr) -> Expr {
8493 Expr::CallExpr(node)
8494 }
8495}
8496impl From<IndexExpr> for Expr {
8497 fn from(node: IndexExpr) -> Expr {
8498 Expr::IndexExpr(node)
8499 }
8500}
8501impl From<MethodCallExpr> for Expr {
8502 fn from(node: MethodCallExpr) -> Expr {
8503 Expr::MethodCallExpr(node)
8504 }
8505}
8506impl From<FieldExpr> for Expr {
8507 fn from(node: FieldExpr) -> Expr {
8508 Expr::FieldExpr(node)
8509 }
8510}
8511impl From<AwaitExpr> for Expr {
8512 fn from(node: AwaitExpr) -> Expr {
8513 Expr::AwaitExpr(node)
8514 }
8515}
8516impl From<TryExpr> for Expr {
8517 fn from(node: TryExpr) -> Expr {
8518 Expr::TryExpr(node)
8519 }
8520}
8521impl From<TryBlockExpr> for Expr {
8522 fn from(node: TryBlockExpr) -> Expr {
8523 Expr::TryBlockExpr(node)
8524 }
8525}
8526impl From<CastExpr> for Expr {
8527 fn from(node: CastExpr) -> Expr {
8528 Expr::CastExpr(node)
8529 }
8530}
8531impl From<RefExpr> for Expr {
8532 fn from(node: RefExpr) -> Expr {
8533 Expr::RefExpr(node)
8534 }
8535}
8536impl From<PrefixExpr> for Expr {
8537 fn from(node: PrefixExpr) -> Expr {
8538 Expr::PrefixExpr(node)
8539 }
8540}
8541impl From<RangeExpr> for Expr {
8542 fn from(node: RangeExpr) -> Expr {
8543 Expr::RangeExpr(node)
8544 }
8545}
8546impl From<BinExpr> for Expr {
8547 fn from(node: BinExpr) -> Expr {
8548 Expr::BinExpr(node)
8549 }
8550}
8551impl From<Literal> for Expr {
8552 fn from(node: Literal) -> Expr {
8553 Expr::Literal(node)
8554 }
8555}
8556impl From<MacroCall> for Expr {
8557 fn from(node: MacroCall) -> Expr {
8558 Expr::MacroCall(node)
8559 }
8560}
8561impl From<BoxExpr> for Expr {
8562 fn from(node: BoxExpr) -> Expr {
8563 Expr::BoxExpr(node)
8564 }
8565}
8566impl std::fmt::Display for Expr {
8567 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8568 std::fmt::Display::fmt(self.syntax(), f)
8569 }
8570}
8571impl AstNode for Expr {
8572 fn can_cast(kind: SyntaxKind) -> bool {
8573 match kind {
8574 TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
8575 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
8576 | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR
8577 | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR
8578 | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL
8579 | BOX_EXPR => true,
8580 _ => false,
8581 }
8582 }
8583 fn cast(syntax: SyntaxNode) -> Option<Self> {
8584 let res = match syntax.kind() {
8585 TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }),
8586 ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }),
8587 PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }),
8588 PATH_EXPR => Expr::PathExpr(PathExpr { syntax }),
8589 LAMBDA_EXPR => Expr::LambdaExpr(LambdaExpr { syntax }),
8590 IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
8591 LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }),
8592 FOR_EXPR => Expr::ForExpr(ForExpr { syntax }),
8593 WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }),
8594 CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }),
8595 BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }),
8596 LABEL => Expr::Label(Label { syntax }),
8597 BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
8598 RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
8599 MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
8600 RECORD_LIT => Expr::RecordLit(RecordLit { syntax }),
8601 CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
8602 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
8603 METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
8604 FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }),
8605 AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }),
8606 TRY_EXPR => Expr::TryExpr(TryExpr { syntax }),
8607 TRY_BLOCK_EXPR => Expr::TryBlockExpr(TryBlockExpr { syntax }),
8608 CAST_EXPR => Expr::CastExpr(CastExpr { syntax }),
8609 REF_EXPR => Expr::RefExpr(RefExpr { syntax }),
8610 PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }),
8611 RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }),
8612 BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
8613 LITERAL => Expr::Literal(Literal { syntax }),
8614 MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
8615 BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }),
8616 _ => return None,
8617 };
8618 Some(res)
8619 }
8620 fn syntax(&self) -> &SyntaxNode {
8621 match self {
8622 Expr::TupleExpr(it) => &it.syntax,
8623 Expr::ArrayExpr(it) => &it.syntax,
8624 Expr::ParenExpr(it) => &it.syntax,
8625 Expr::PathExpr(it) => &it.syntax,
8626 Expr::LambdaExpr(it) => &it.syntax,
8627 Expr::IfExpr(it) => &it.syntax,
8628 Expr::LoopExpr(it) => &it.syntax,
8629 Expr::ForExpr(it) => &it.syntax,
8630 Expr::WhileExpr(it) => &it.syntax,
8631 Expr::ContinueExpr(it) => &it.syntax,
8632 Expr::BreakExpr(it) => &it.syntax,
8633 Expr::Label(it) => &it.syntax,
8634 Expr::BlockExpr(it) => &it.syntax,
8635 Expr::ReturnExpr(it) => &it.syntax,
8636 Expr::MatchExpr(it) => &it.syntax,
8637 Expr::RecordLit(it) => &it.syntax,
8638 Expr::CallExpr(it) => &it.syntax,
8639 Expr::IndexExpr(it) => &it.syntax,
8640 Expr::MethodCallExpr(it) => &it.syntax,
8641 Expr::FieldExpr(it) => &it.syntax,
8642 Expr::AwaitExpr(it) => &it.syntax,
8643 Expr::TryExpr(it) => &it.syntax,
8644 Expr::TryBlockExpr(it) => &it.syntax,
8645 Expr::CastExpr(it) => &it.syntax,
8646 Expr::RefExpr(it) => &it.syntax,
8647 Expr::PrefixExpr(it) => &it.syntax,
8648 Expr::RangeExpr(it) => &it.syntax,
8649 Expr::BinExpr(it) => &it.syntax,
8650 Expr::Literal(it) => &it.syntax,
8651 Expr::MacroCall(it) => &it.syntax,
8652 Expr::BoxExpr(it) => &it.syntax,
8653 }
8654 }
8655}
8656impl ast::AttrsOwner for Expr {}
8657#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8658pub enum Pat {
8659 OrPat(OrPat),
8660 ParenPat(ParenPat),
8661 RefPat(RefPat),
8662 BoxPat(BoxPat),
8663 BindPat(BindPat),
8664 PlaceholderPat(PlaceholderPat),
8665 DotDotPat(DotDotPat),
8666 PathPat(PathPat),
8667 RecordPat(RecordPat),
8668 TupleStructPat(TupleStructPat),
8669 TuplePat(TuplePat),
8670 SlicePat(SlicePat),
8671 RangePat(RangePat),
8672 LiteralPat(LiteralPat),
8673 MacroPat(MacroPat),
8674}
8675impl From<OrPat> for Pat {
8676 fn from(node: OrPat) -> Pat {
8677 Pat::OrPat(node)
8678 }
8679}
8680impl From<ParenPat> for Pat {
8681 fn from(node: ParenPat) -> Pat {
8682 Pat::ParenPat(node)
8683 }
8684}
8685impl From<RefPat> for Pat {
8686 fn from(node: RefPat) -> Pat {
8687 Pat::RefPat(node)
8688 }
8689}
8690impl From<BoxPat> for Pat {
8691 fn from(node: BoxPat) -> Pat {
8692 Pat::BoxPat(node)
8693 }
8694}
8695impl From<BindPat> for Pat {
8696 fn from(node: BindPat) -> Pat {
8697 Pat::BindPat(node)
8698 }
8699}
8700impl From<PlaceholderPat> for Pat {
8701 fn from(node: PlaceholderPat) -> Pat {
8702 Pat::PlaceholderPat(node)
8703 }
8704}
8705impl From<DotDotPat> for Pat {
8706 fn from(node: DotDotPat) -> Pat {
8707 Pat::DotDotPat(node)
8708 }
8709}
8710impl From<PathPat> for Pat {
8711 fn from(node: PathPat) -> Pat {
8712 Pat::PathPat(node)
8713 }
8714}
8715impl From<RecordPat> for Pat {
8716 fn from(node: RecordPat) -> Pat {
8717 Pat::RecordPat(node)
8718 }
8719}
8720impl From<TupleStructPat> for Pat {
8721 fn from(node: TupleStructPat) -> Pat {
8722 Pat::TupleStructPat(node)
8723 }
8724}
8725impl From<TuplePat> for Pat {
8726 fn from(node: TuplePat) -> Pat {
8727 Pat::TuplePat(node)
8728 }
8729}
8730impl From<SlicePat> for Pat {
8731 fn from(node: SlicePat) -> Pat {
8732 Pat::SlicePat(node)
8733 }
8734}
8735impl From<RangePat> for Pat {
8736 fn from(node: RangePat) -> Pat {
8737 Pat::RangePat(node)
8738 }
8739}
8740impl From<LiteralPat> for Pat {
8741 fn from(node: LiteralPat) -> Pat {
8742 Pat::LiteralPat(node)
8743 }
8744}
8745impl From<MacroPat> for Pat {
8746 fn from(node: MacroPat) -> Pat {
8747 Pat::MacroPat(node)
8748 }
8749}
8750impl std::fmt::Display for Pat {
8751 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8752 std::fmt::Display::fmt(self.syntax(), f)
8753 }
8754}
8755impl AstNode for Pat {
8756 fn can_cast(kind: SyntaxKind) -> bool {
8757 match kind {
8758 OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT
8759 | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT
8760 | LITERAL_PAT | MACRO_PAT => true,
8761 _ => false,
8762 }
8763 }
8764 fn cast(syntax: SyntaxNode) -> Option<Self> {
8765 let res = match syntax.kind() {
8766 OR_PAT => Pat::OrPat(OrPat { syntax }),
8767 PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
8768 REF_PAT => Pat::RefPat(RefPat { syntax }),
8769 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
8770 BIND_PAT => Pat::BindPat(BindPat { syntax }),
8771 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
8772 DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
8773 PATH_PAT => Pat::PathPat(PathPat { syntax }),
8774 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
8775 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
8776 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
8777 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
8778 RANGE_PAT => Pat::RangePat(RangePat { syntax }),
8779 LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
8780 MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
8781 _ => return None,
8782 };
8783 Some(res)
8784 }
8785 fn syntax(&self) -> &SyntaxNode {
8786 match self {
8787 Pat::OrPat(it) => &it.syntax,
8788 Pat::ParenPat(it) => &it.syntax,
8789 Pat::RefPat(it) => &it.syntax,
8790 Pat::BoxPat(it) => &it.syntax,
8791 Pat::BindPat(it) => &it.syntax,
8792 Pat::PlaceholderPat(it) => &it.syntax,
8793 Pat::DotDotPat(it) => &it.syntax,
8794 Pat::PathPat(it) => &it.syntax,
8795 Pat::RecordPat(it) => &it.syntax,
8796 Pat::TupleStructPat(it) => &it.syntax,
8797 Pat::TuplePat(it) => &it.syntax,
8798 Pat::SlicePat(it) => &it.syntax,
8799 Pat::RangePat(it) => &it.syntax,
8800 Pat::LiteralPat(it) => &it.syntax,
8801 Pat::MacroPat(it) => &it.syntax,
8802 }
8803 }
8804}
8805#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8806pub enum RecordInnerPat {
8807 RecordFieldPat(RecordFieldPat),
8808 BindPat(BindPat),
8809}
8810impl From<RecordFieldPat> for RecordInnerPat {
8811 fn from(node: RecordFieldPat) -> RecordInnerPat {
8812 RecordInnerPat::RecordFieldPat(node)
8813 }
8814}
8815impl From<BindPat> for RecordInnerPat {
8816 fn from(node: BindPat) -> RecordInnerPat {
8817 RecordInnerPat::BindPat(node)
8818 }
8819}
8820impl std::fmt::Display for RecordInnerPat {
8821 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8822 std::fmt::Display::fmt(self.syntax(), f)
8823 }
8824}
8825impl AstNode for RecordInnerPat {
8826 fn can_cast(kind: SyntaxKind) -> bool {
8827 match kind {
8828 RECORD_FIELD_PAT | BIND_PAT => true,
8829 _ => false,
8830 }
8831 }
8832 fn cast(syntax: SyntaxNode) -> Option<Self> {
8833 let res = match syntax.kind() {
8834 RECORD_FIELD_PAT => RecordInnerPat::RecordFieldPat(RecordFieldPat { syntax }),
8835 BIND_PAT => RecordInnerPat::BindPat(BindPat { syntax }),
8836 _ => return None,
8837 };
8838 Some(res)
8839 }
8840 fn syntax(&self) -> &SyntaxNode {
8841 match self {
8842 RecordInnerPat::RecordFieldPat(it) => &it.syntax,
8843 RecordInnerPat::BindPat(it) => &it.syntax,
8844 }
8845 }
8846}
8847#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8848pub enum AttrInput {
8849 Literal(Literal),
8850 TokenTree(TokenTree),
8851}
8852impl From<Literal> for AttrInput {
8853 fn from(node: Literal) -> AttrInput {
8854 AttrInput::Literal(node)
8855 }
8856}
8857impl From<TokenTree> for AttrInput {
8858 fn from(node: TokenTree) -> AttrInput {
8859 AttrInput::TokenTree(node)
8860 }
8861}
8862impl std::fmt::Display for AttrInput {
8863 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8864 std::fmt::Display::fmt(self.syntax(), f)
8865 }
8866}
8867impl AstNode for AttrInput {
8868 fn can_cast(kind: SyntaxKind) -> bool {
8869 match kind {
8870 LITERAL | TOKEN_TREE => true,
8871 _ => false,
8872 }
8873 }
8874 fn cast(syntax: SyntaxNode) -> Option<Self> {
8875 let res = match syntax.kind() {
8876 LITERAL => AttrInput::Literal(Literal { syntax }),
8877 TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }),
8878 _ => return None,
8879 };
8880 Some(res)
8881 }
8882 fn syntax(&self) -> &SyntaxNode {
8883 match self {
8884 AttrInput::Literal(it) => &it.syntax,
8885 AttrInput::TokenTree(it) => &it.syntax,
8886 }
8887 }
8888}
8889#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8890pub enum Stmt {
8891 LetStmt(LetStmt),
8892 ExprStmt(ExprStmt),
8893}
8894impl From<LetStmt> for Stmt {
8895 fn from(node: LetStmt) -> Stmt {
8896 Stmt::LetStmt(node)
8897 }
8898}
8899impl From<ExprStmt> for Stmt {
8900 fn from(node: ExprStmt) -> Stmt {
8901 Stmt::ExprStmt(node)
8902 }
8903}
8904impl std::fmt::Display for Stmt {
8905 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8906 std::fmt::Display::fmt(self.syntax(), f)
8907 }
8908}
8909impl AstNode for Stmt {
8910 fn can_cast(kind: SyntaxKind) -> bool {
8911 match kind {
8912 LET_STMT | EXPR_STMT => true,
8913 _ => false,
8914 }
8915 }
8916 fn cast(syntax: SyntaxNode) -> Option<Self> {
8917 let res = match syntax.kind() {
8918 LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
8919 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
8920 _ => return None,
8921 };
8922 Some(res)
8923 }
8924 fn syntax(&self) -> &SyntaxNode {
8925 match self {
8926 Stmt::LetStmt(it) => &it.syntax,
8927 Stmt::ExprStmt(it) => &it.syntax,
8928 }
8929 }
8930}
8931#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8932pub enum LeftDelimiter {
8933 LParen(LParen),
8934 LBrack(LBrack),
8935 LCurly(LCurly),
8936}
8937impl From<LParen> for LeftDelimiter {
8938 fn from(node: LParen) -> LeftDelimiter {
8939 LeftDelimiter::LParen(node)
8940 }
8941}
8942impl From<LBrack> for LeftDelimiter {
8943 fn from(node: LBrack) -> LeftDelimiter {
8944 LeftDelimiter::LBrack(node)
8945 }
8946}
8947impl From<LCurly> for LeftDelimiter {
8948 fn from(node: LCurly) -> LeftDelimiter {
8949 LeftDelimiter::LCurly(node)
8950 }
8951}
8952impl std::fmt::Display for LeftDelimiter {
8953 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8954 std::fmt::Display::fmt(self.syntax(), f)
8955 }
8956}
8957impl AstToken for LeftDelimiter {
8958 fn can_cast(kind: SyntaxKind) -> bool {
8959 match kind {
8960 L_PAREN | L_BRACK | L_CURLY => true,
8961 _ => false,
8962 }
8963 }
8964 fn cast(syntax: SyntaxToken) -> Option<Self> {
8965 let res = match syntax.kind() {
8966 L_PAREN => LeftDelimiter::LParen(LParen { syntax }),
8967 L_BRACK => LeftDelimiter::LBrack(LBrack { syntax }),
8968 L_CURLY => LeftDelimiter::LCurly(LCurly { syntax }),
8969 _ => return None,
8970 };
8971 Some(res)
8972 }
8973 fn syntax(&self) -> &SyntaxToken {
8974 match self {
8975 LeftDelimiter::LParen(it) => &it.syntax,
8976 LeftDelimiter::LBrack(it) => &it.syntax,
8977 LeftDelimiter::LCurly(it) => &it.syntax,
8978 }
8979 }
8980}
8981#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8982pub enum RightDelimiter {
8983 RParen(RParen),
8984 RBrack(RBrack),
8985 RCurly(RCurly),
8986}
8987impl From<RParen> for RightDelimiter {
8988 fn from(node: RParen) -> RightDelimiter {
8989 RightDelimiter::RParen(node)
8990 }
8991}
8992impl From<RBrack> for RightDelimiter {
8993 fn from(node: RBrack) -> RightDelimiter {
8994 RightDelimiter::RBrack(node)
8995 }
8996}
8997impl From<RCurly> for RightDelimiter {
8998 fn from(node: RCurly) -> RightDelimiter {
8999 RightDelimiter::RCurly(node)
9000 }
9001}
9002impl std::fmt::Display for RightDelimiter {
9003 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9004 std::fmt::Display::fmt(self.syntax(), f)
9005 }
9006}
9007impl AstToken for RightDelimiter {
9008 fn can_cast(kind: SyntaxKind) -> bool {
9009 match kind {
9010 R_PAREN | R_BRACK | R_CURLY => true,
9011 _ => false,
9012 }
9013 }
9014 fn cast(syntax: SyntaxToken) -> Option<Self> {
9015 let res = match syntax.kind() {
9016 R_PAREN => RightDelimiter::RParen(RParen { syntax }),
9017 R_BRACK => RightDelimiter::RBrack(RBrack { syntax }),
9018 R_CURLY => RightDelimiter::RCurly(RCurly { syntax }),
9019 _ => return None,
9020 };
9021 Some(res)
9022 }
9023 fn syntax(&self) -> &SyntaxToken {
9024 match self {
9025 RightDelimiter::RParen(it) => &it.syntax,
9026 RightDelimiter::RBrack(it) => &it.syntax,
9027 RightDelimiter::RCurly(it) => &it.syntax,
9028 }
9029 }
9030}
9031#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9032pub enum RangeSeparator {
9033 Dotdot(Dotdot),
9034 Dotdotdot(Dotdotdot),
9035 Dotdoteq(Dotdoteq),
9036}
9037impl From<Dotdot> for RangeSeparator {
9038 fn from(node: Dotdot) -> RangeSeparator {
9039 RangeSeparator::Dotdot(node)
9040 }
9041}
9042impl From<Dotdotdot> for RangeSeparator {
9043 fn from(node: Dotdotdot) -> RangeSeparator {
9044 RangeSeparator::Dotdotdot(node)
9045 }
9046}
9047impl From<Dotdoteq> for RangeSeparator {
9048 fn from(node: Dotdoteq) -> RangeSeparator {
9049 RangeSeparator::Dotdoteq(node)
9050 }
9051}
9052impl std::fmt::Display for RangeSeparator {
9053 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9054 std::fmt::Display::fmt(self.syntax(), f)
9055 }
9056}
9057impl AstToken for RangeSeparator {
9058 fn can_cast(kind: SyntaxKind) -> bool {
9059 match kind {
9060 DOTDOT | DOTDOTDOT | DOTDOTEQ => true,
9061 _ => false,
9062 }
9063 }
9064 fn cast(syntax: SyntaxToken) -> Option<Self> {
9065 let res = match syntax.kind() {
9066 DOTDOT => RangeSeparator::Dotdot(Dotdot { syntax }),
9067 DOTDOTDOT => RangeSeparator::Dotdotdot(Dotdotdot { syntax }),
9068 DOTDOTEQ => RangeSeparator::Dotdoteq(Dotdoteq { syntax }),
9069 _ => return None,
9070 };
9071 Some(res)
9072 }
9073 fn syntax(&self) -> &SyntaxToken {
9074 match self {
9075 RangeSeparator::Dotdot(it) => &it.syntax,
9076 RangeSeparator::Dotdotdot(it) => &it.syntax,
9077 RangeSeparator::Dotdoteq(it) => &it.syntax,
9078 }
9079 }
9080}
9081#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9082pub enum BinOp {
9083 Pipepipe(Pipepipe),
9084 Ampamp(Ampamp),
9085 Eqeq(Eqeq),
9086 Neq(Neq),
9087 Lteq(Lteq),
9088 Gteq(Gteq),
9089 LAngle(LAngle),
9090 RAngle(RAngle),
9091 Plus(Plus),
9092 Star(Star),
9093 Minus(Minus),
9094 Slash(Slash),
9095 Percent(Percent),
9096 Shl(Shl),
9097 Shr(Shr),
9098 Caret(Caret),
9099 Pipe(Pipe),
9100 Amp(Amp),
9101 Eq(Eq),
9102 Pluseq(Pluseq),
9103 Slasheq(Slasheq),
9104 Stareq(Stareq),
9105 Percenteq(Percenteq),
9106 Shreq(Shreq),
9107 Shleq(Shleq),
9108 Minuseq(Minuseq),
9109 Pipeeq(Pipeeq),
9110 Ampeq(Ampeq),
9111 Careteq(Careteq),
9112}
9113impl From<Pipepipe> for BinOp {
9114 fn from(node: Pipepipe) -> BinOp {
9115 BinOp::Pipepipe(node)
9116 }
9117}
9118impl From<Ampamp> for BinOp {
9119 fn from(node: Ampamp) -> BinOp {
9120 BinOp::Ampamp(node)
9121 }
9122}
9123impl From<Eqeq> for BinOp {
9124 fn from(node: Eqeq) -> BinOp {
9125 BinOp::Eqeq(node)
9126 }
9127}
9128impl From<Neq> for BinOp {
9129 fn from(node: Neq) -> BinOp {
9130 BinOp::Neq(node)
9131 }
9132}
9133impl From<Lteq> for BinOp {
9134 fn from(node: Lteq) -> BinOp {
9135 BinOp::Lteq(node)
9136 }
9137}
9138impl From<Gteq> for BinOp {
9139 fn from(node: Gteq) -> BinOp {
9140 BinOp::Gteq(node)
9141 }
9142}
9143impl From<LAngle> for BinOp {
9144 fn from(node: LAngle) -> BinOp {
9145 BinOp::LAngle(node)
9146 }
9147}
9148impl From<RAngle> for BinOp {
9149 fn from(node: RAngle) -> BinOp {
9150 BinOp::RAngle(node)
9151 }
9152}
9153impl From<Plus> for BinOp {
9154 fn from(node: Plus) -> BinOp {
9155 BinOp::Plus(node)
9156 }
9157}
9158impl From<Star> for BinOp {
9159 fn from(node: Star) -> BinOp {
9160 BinOp::Star(node)
9161 }
9162}
9163impl From<Minus> for BinOp {
9164 fn from(node: Minus) -> BinOp {
9165 BinOp::Minus(node)
9166 }
9167}
9168impl From<Slash> for BinOp {
9169 fn from(node: Slash) -> BinOp {
9170 BinOp::Slash(node)
9171 }
9172}
9173impl From<Percent> for BinOp {
9174 fn from(node: Percent) -> BinOp {
9175 BinOp::Percent(node)
9176 }
9177}
9178impl From<Shl> for BinOp {
9179 fn from(node: Shl) -> BinOp {
9180 BinOp::Shl(node)
9181 }
9182}
9183impl From<Shr> for BinOp {
9184 fn from(node: Shr) -> BinOp {
9185 BinOp::Shr(node)
9186 }
9187}
9188impl From<Caret> for BinOp {
9189 fn from(node: Caret) -> BinOp {
9190 BinOp::Caret(node)
9191 }
9192}
9193impl From<Pipe> for BinOp {
9194 fn from(node: Pipe) -> BinOp {
9195 BinOp::Pipe(node)
9196 }
9197}
9198impl From<Amp> for BinOp {
9199 fn from(node: Amp) -> BinOp {
9200 BinOp::Amp(node)
9201 }
9202}
9203impl From<Eq> for BinOp {
9204 fn from(node: Eq) -> BinOp {
9205 BinOp::Eq(node)
9206 }
9207}
9208impl From<Pluseq> for BinOp {
9209 fn from(node: Pluseq) -> BinOp {
9210 BinOp::Pluseq(node)
9211 }
9212}
9213impl From<Slasheq> for BinOp {
9214 fn from(node: Slasheq) -> BinOp {
9215 BinOp::Slasheq(node)
9216 }
9217}
9218impl From<Stareq> for BinOp {
9219 fn from(node: Stareq) -> BinOp {
9220 BinOp::Stareq(node)
9221 }
9222}
9223impl From<Percenteq> for BinOp {
9224 fn from(node: Percenteq) -> BinOp {
9225 BinOp::Percenteq(node)
9226 }
9227}
9228impl From<Shreq> for BinOp {
9229 fn from(node: Shreq) -> BinOp {
9230 BinOp::Shreq(node)
9231 }
9232}
9233impl From<Shleq> for BinOp {
9234 fn from(node: Shleq) -> BinOp {
9235 BinOp::Shleq(node)
9236 }
9237}
9238impl From<Minuseq> for BinOp {
9239 fn from(node: Minuseq) -> BinOp {
9240 BinOp::Minuseq(node)
9241 }
9242}
9243impl From<Pipeeq> for BinOp {
9244 fn from(node: Pipeeq) -> BinOp {
9245 BinOp::Pipeeq(node)
9246 }
9247}
9248impl From<Ampeq> for BinOp {
9249 fn from(node: Ampeq) -> BinOp {
9250 BinOp::Ampeq(node)
9251 }
9252}
9253impl From<Careteq> for BinOp {
9254 fn from(node: Careteq) -> BinOp {
9255 BinOp::Careteq(node)
9256 }
9257}
9258impl std::fmt::Display for BinOp {
9259 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9260 std::fmt::Display::fmt(self.syntax(), f)
9261 }
9262}
9263impl AstToken for BinOp {
9264 fn can_cast(kind: SyntaxKind) -> bool {
9265 match kind {
9266 PIPEPIPE | AMPAMP | EQEQ | NEQ | LTEQ | GTEQ | L_ANGLE | R_ANGLE | PLUS | STAR
9267 | MINUS | SLASH | PERCENT | SHL | SHR | CARET | PIPE | AMP | EQ | PLUSEQ | SLASHEQ
9268 | STAREQ | PERCENTEQ | SHREQ | SHLEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ => true,
9269 _ => false,
9270 }
9271 }
9272 fn cast(syntax: SyntaxToken) -> Option<Self> {
9273 let res = match syntax.kind() {
9274 PIPEPIPE => BinOp::Pipepipe(Pipepipe { syntax }),
9275 AMPAMP => BinOp::Ampamp(Ampamp { syntax }),
9276 EQEQ => BinOp::Eqeq(Eqeq { syntax }),
9277 NEQ => BinOp::Neq(Neq { syntax }),
9278 LTEQ => BinOp::Lteq(Lteq { syntax }),
9279 GTEQ => BinOp::Gteq(Gteq { syntax }),
9280 L_ANGLE => BinOp::LAngle(LAngle { syntax }),
9281 R_ANGLE => BinOp::RAngle(RAngle { syntax }),
9282 PLUS => BinOp::Plus(Plus { syntax }),
9283 STAR => BinOp::Star(Star { syntax }),
9284 MINUS => BinOp::Minus(Minus { syntax }),
9285 SLASH => BinOp::Slash(Slash { syntax }),
9286 PERCENT => BinOp::Percent(Percent { syntax }),
9287 SHL => BinOp::Shl(Shl { syntax }),
9288 SHR => BinOp::Shr(Shr { syntax }),
9289 CARET => BinOp::Caret(Caret { syntax }),
9290 PIPE => BinOp::Pipe(Pipe { syntax }),
9291 AMP => BinOp::Amp(Amp { syntax }),
9292 EQ => BinOp::Eq(Eq { syntax }),
9293 PLUSEQ => BinOp::Pluseq(Pluseq { syntax }),
9294 SLASHEQ => BinOp::Slasheq(Slasheq { syntax }),
9295 STAREQ => BinOp::Stareq(Stareq { syntax }),
9296 PERCENTEQ => BinOp::Percenteq(Percenteq { syntax }),
9297 SHREQ => BinOp::Shreq(Shreq { syntax }),
9298 SHLEQ => BinOp::Shleq(Shleq { syntax }),
9299 MINUSEQ => BinOp::Minuseq(Minuseq { syntax }),
9300 PIPEEQ => BinOp::Pipeeq(Pipeeq { syntax }),
9301 AMPEQ => BinOp::Ampeq(Ampeq { syntax }),
9302 CARETEQ => BinOp::Careteq(Careteq { syntax }),
9303 _ => return None,
9304 };
9305 Some(res)
9306 }
9307 fn syntax(&self) -> &SyntaxToken {
9308 match self {
9309 BinOp::Pipepipe(it) => &it.syntax,
9310 BinOp::Ampamp(it) => &it.syntax,
9311 BinOp::Eqeq(it) => &it.syntax,
9312 BinOp::Neq(it) => &it.syntax,
9313 BinOp::Lteq(it) => &it.syntax,
9314 BinOp::Gteq(it) => &it.syntax,
9315 BinOp::LAngle(it) => &it.syntax,
9316 BinOp::RAngle(it) => &it.syntax,
9317 BinOp::Plus(it) => &it.syntax,
9318 BinOp::Star(it) => &it.syntax,
9319 BinOp::Minus(it) => &it.syntax,
9320 BinOp::Slash(it) => &it.syntax,
9321 BinOp::Percent(it) => &it.syntax,
9322 BinOp::Shl(it) => &it.syntax,
9323 BinOp::Shr(it) => &it.syntax,
9324 BinOp::Caret(it) => &it.syntax,
9325 BinOp::Pipe(it) => &it.syntax,
9326 BinOp::Amp(it) => &it.syntax,
9327 BinOp::Eq(it) => &it.syntax,
9328 BinOp::Pluseq(it) => &it.syntax,
9329 BinOp::Slasheq(it) => &it.syntax,
9330 BinOp::Stareq(it) => &it.syntax,
9331 BinOp::Percenteq(it) => &it.syntax,
9332 BinOp::Shreq(it) => &it.syntax,
9333 BinOp::Shleq(it) => &it.syntax,
9334 BinOp::Minuseq(it) => &it.syntax,
9335 BinOp::Pipeeq(it) => &it.syntax,
9336 BinOp::Ampeq(it) => &it.syntax,
9337 BinOp::Careteq(it) => &it.syntax,
9338 }
9339 }
9340}
9341#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9342pub enum PrefixOp {
9343 Minus(Minus),
9344 Excl(Excl),
9345 Star(Star),
9346}
9347impl From<Minus> for PrefixOp {
9348 fn from(node: Minus) -> PrefixOp {
9349 PrefixOp::Minus(node)
9350 }
9351}
9352impl From<Excl> for PrefixOp {
9353 fn from(node: Excl) -> PrefixOp {
9354 PrefixOp::Excl(node)
9355 }
9356}
9357impl From<Star> for PrefixOp {
9358 fn from(node: Star) -> PrefixOp {
9359 PrefixOp::Star(node)
9360 }
9361}
9362impl std::fmt::Display for PrefixOp {
9363 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9364 std::fmt::Display::fmt(self.syntax(), f)
9365 }
9366}
9367impl AstToken for PrefixOp {
9368 fn can_cast(kind: SyntaxKind) -> bool {
9369 match kind {
9370 MINUS | EXCL | STAR => true,
9371 _ => false,
9372 }
9373 }
9374 fn cast(syntax: SyntaxToken) -> Option<Self> {
9375 let res = match syntax.kind() {
9376 MINUS => PrefixOp::Minus(Minus { syntax }),
9377 EXCL => PrefixOp::Excl(Excl { syntax }),
9378 STAR => PrefixOp::Star(Star { syntax }),
9379 _ => return None,
9380 };
9381 Some(res)
9382 }
9383 fn syntax(&self) -> &SyntaxToken {
9384 match self {
9385 PrefixOp::Minus(it) => &it.syntax,
9386 PrefixOp::Excl(it) => &it.syntax,
9387 PrefixOp::Star(it) => &it.syntax,
9388 }
9389 }
9390}
9391#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9392pub enum RangeOp {
9393 Dotdot(Dotdot),
9394 Dotdoteq(Dotdoteq),
9395}
9396impl From<Dotdot> for RangeOp {
9397 fn from(node: Dotdot) -> RangeOp {
9398 RangeOp::Dotdot(node)
9399 }
9400}
9401impl From<Dotdoteq> for RangeOp {
9402 fn from(node: Dotdoteq) -> RangeOp {
9403 RangeOp::Dotdoteq(node)
9404 }
9405}
9406impl std::fmt::Display for RangeOp {
9407 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9408 std::fmt::Display::fmt(self.syntax(), f)
9409 }
9410}
9411impl AstToken for RangeOp {
9412 fn can_cast(kind: SyntaxKind) -> bool {
9413 match kind {
9414 DOTDOT | DOTDOTEQ => true,
9415 _ => false,
9416 }
9417 }
9418 fn cast(syntax: SyntaxToken) -> Option<Self> {
9419 let res = match syntax.kind() {
9420 DOTDOT => RangeOp::Dotdot(Dotdot { syntax }),
9421 DOTDOTEQ => RangeOp::Dotdoteq(Dotdoteq { syntax }),
9422 _ => return None,
9423 };
9424 Some(res)
9425 }
9426 fn syntax(&self) -> &SyntaxToken {
9427 match self {
9428 RangeOp::Dotdot(it) => &it.syntax,
9429 RangeOp::Dotdoteq(it) => &it.syntax,
9430 }
9431 }
9432}
9433#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9434pub enum LiteralToken {
9435 IntNumber(IntNumber),
9436 FloatNumber(FloatNumber),
9437 String(String),
9438 RawString(RawString),
9439 TrueKw(TrueKw),
9440 FalseKw(FalseKw),
9441 ByteString(ByteString),
9442 RawByteString(RawByteString),
9443 Char(Char),
9444 Byte(Byte),
9445}
9446impl From<IntNumber> for LiteralToken {
9447 fn from(node: IntNumber) -> LiteralToken {
9448 LiteralToken::IntNumber(node)
9449 }
9450}
9451impl From<FloatNumber> for LiteralToken {
9452 fn from(node: FloatNumber) -> LiteralToken {
9453 LiteralToken::FloatNumber(node)
9454 }
9455}
9456impl From<String> for LiteralToken {
9457 fn from(node: String) -> LiteralToken {
9458 LiteralToken::String(node)
9459 }
9460}
9461impl From<RawString> for LiteralToken {
9462 fn from(node: RawString) -> LiteralToken {
9463 LiteralToken::RawString(node)
9464 }
9465}
9466impl From<TrueKw> for LiteralToken {
9467 fn from(node: TrueKw) -> LiteralToken {
9468 LiteralToken::TrueKw(node)
9469 }
9470}
9471impl From<FalseKw> for LiteralToken {
9472 fn from(node: FalseKw) -> LiteralToken {
9473 LiteralToken::FalseKw(node)
9474 }
9475}
9476impl From<ByteString> for LiteralToken {
9477 fn from(node: ByteString) -> LiteralToken {
9478 LiteralToken::ByteString(node)
9479 }
9480}
9481impl From<RawByteString> for LiteralToken {
9482 fn from(node: RawByteString) -> LiteralToken {
9483 LiteralToken::RawByteString(node)
9484 }
9485}
9486impl From<Char> for LiteralToken {
9487 fn from(node: Char) -> LiteralToken {
9488 LiteralToken::Char(node)
9489 }
9490}
9491impl From<Byte> for LiteralToken {
9492 fn from(node: Byte) -> LiteralToken {
9493 LiteralToken::Byte(node)
9494 }
9495}
9496impl std::fmt::Display for LiteralToken {
9497 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9498 std::fmt::Display::fmt(self.syntax(), f)
9499 }
9500}
9501impl AstToken for LiteralToken {
9502 fn can_cast(kind: SyntaxKind) -> bool {
9503 match kind {
9504 INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | TRUE_KW | FALSE_KW | BYTE_STRING
9505 | RAW_BYTE_STRING | CHAR | BYTE => true,
9506 _ => false,
9507 }
9508 }
9509 fn cast(syntax: SyntaxToken) -> Option<Self> {
9510 let res = match syntax.kind() {
9511 INT_NUMBER => LiteralToken::IntNumber(IntNumber { syntax }),
9512 FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }),
9513 STRING => LiteralToken::String(String { syntax }),
9514 RAW_STRING => LiteralToken::RawString(RawString { syntax }),
9515 TRUE_KW => LiteralToken::TrueKw(TrueKw { syntax }),
9516 FALSE_KW => LiteralToken::FalseKw(FalseKw { syntax }),
9517 BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }),
9518 RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }),
9519 CHAR => LiteralToken::Char(Char { syntax }),
9520 BYTE => LiteralToken::Byte(Byte { syntax }),
9521 _ => return None,
9522 };
9523 Some(res)
9524 }
9525 fn syntax(&self) -> &SyntaxToken {
9526 match self {
9527 LiteralToken::IntNumber(it) => &it.syntax,
9528 LiteralToken::FloatNumber(it) => &it.syntax,
9529 LiteralToken::String(it) => &it.syntax,
9530 LiteralToken::RawString(it) => &it.syntax,
9531 LiteralToken::TrueKw(it) => &it.syntax,
9532 LiteralToken::FalseKw(it) => &it.syntax,
9533 LiteralToken::ByteString(it) => &it.syntax,
9534 LiteralToken::RawByteString(it) => &it.syntax,
9535 LiteralToken::Char(it) => &it.syntax,
9536 LiteralToken::Byte(it) => &it.syntax,
9537 }
9538 }
9539}
9540#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9541pub enum NameRefToken {
9542 Ident(Ident),
9543 IntNumber(IntNumber),
9544}
9545impl From<Ident> for NameRefToken {
9546 fn from(node: Ident) -> NameRefToken {
9547 NameRefToken::Ident(node)
9548 }
9549}
9550impl From<IntNumber> for NameRefToken {
9551 fn from(node: IntNumber) -> NameRefToken {
9552 NameRefToken::IntNumber(node)
9553 }
9554}
9555impl std::fmt::Display for NameRefToken {
9556 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9557 std::fmt::Display::fmt(self.syntax(), f)
9558 }
9559}
9560impl AstToken for NameRefToken {
9561 fn can_cast(kind: SyntaxKind) -> bool {
9562 match kind {
9563 IDENT | INT_NUMBER => true,
9564 _ => false,
9565 }
9566 }
9567 fn cast(syntax: SyntaxToken) -> Option<Self> {
9568 let res = match syntax.kind() {
9569 IDENT => NameRefToken::Ident(Ident { syntax }),
9570 INT_NUMBER => NameRefToken::IntNumber(IntNumber { syntax }),
9571 _ => return None,
9572 };
9573 Some(res)
9574 }
9575 fn syntax(&self) -> &SyntaxToken {
9576 match self {
9577 NameRefToken::Ident(it) => &it.syntax,
9578 NameRefToken::IntNumber(it) => &it.syntax,
9579 }
9580 }
9581}
9582#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9583pub enum FieldDefList {
9584 RecordFieldDefList(RecordFieldDefList),
9585 TupleFieldDefList(TupleFieldDefList),
9586}
9587impl From<RecordFieldDefList> for FieldDefList {
9588 fn from(node: RecordFieldDefList) -> FieldDefList {
9589 FieldDefList::RecordFieldDefList(node)
9590 }
9591}
9592impl From<TupleFieldDefList> for FieldDefList {
9593 fn from(node: TupleFieldDefList) -> FieldDefList {
9594 FieldDefList::TupleFieldDefList(node)
9595 }
9596}
9597impl std::fmt::Display for FieldDefList {
9598 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9599 std::fmt::Display::fmt(self.syntax(), f)
9600 }
9601}
9602impl AstNode for FieldDefList {
9603 fn can_cast(kind: SyntaxKind) -> bool {
9604 match kind {
9605 RECORD_FIELD_DEF_LIST | TUPLE_FIELD_DEF_LIST => true,
9606 _ => false,
9607 }
9608 }
9609 fn cast(syntax: SyntaxNode) -> Option<Self> {
9610 let res = match syntax.kind() {
9611 RECORD_FIELD_DEF_LIST => {
9612 FieldDefList::RecordFieldDefList(RecordFieldDefList { syntax })
9613 }
9614 TUPLE_FIELD_DEF_LIST => FieldDefList::TupleFieldDefList(TupleFieldDefList { syntax }),
9615 _ => return None,
9616 };
9617 Some(res)
9618 }
9619 fn syntax(&self) -> &SyntaxNode {
9620 match self {
9621 FieldDefList::RecordFieldDefList(it) => &it.syntax,
9622 FieldDefList::TupleFieldDefList(it) => &it.syntax,
9623 }
9624 }
9625}
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
new file mode 100644
index 000000000..bd92e9c87
--- /dev/null
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -0,0 +1,9625 @@
1//! Generated file, do not edit by hand, see `xtask/src/codegen`
2
3#[allow(unused_imports)]
4use crate::{
5 ast::{self, support, AstChildren, AstNode, AstToken},
6 NodeOrToken, SyntaxElement,
7 SyntaxKind::{self, *},
8 SyntaxNode, SyntaxToken,
9};
10#[derive(Debug, Clone, PartialEq, Eq, Hash)]
11pub struct Semi {
12 pub(crate) syntax: SyntaxToken,
13}
14impl std::fmt::Display for Semi {
15 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
16 std::fmt::Display::fmt(&self.syntax, f)
17 }
18}
19impl AstToken for Semi {
20 fn can_cast(kind: SyntaxKind) -> bool {
21 match kind {
22 SEMI => true,
23 _ => false,
24 }
25 }
26 fn cast(syntax: SyntaxToken) -> Option<Self> {
27 if Self::can_cast(syntax.kind()) {
28 Some(Self { syntax })
29 } else {
30 None
31 }
32 }
33 fn syntax(&self) -> &SyntaxToken {
34 &self.syntax
35 }
36}
37#[derive(Debug, Clone, PartialEq, Eq, Hash)]
38pub struct Comma {
39 pub(crate) syntax: SyntaxToken,
40}
41impl std::fmt::Display for Comma {
42 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
43 std::fmt::Display::fmt(&self.syntax, f)
44 }
45}
46impl AstToken for Comma {
47 fn can_cast(kind: SyntaxKind) -> bool {
48 match kind {
49 COMMA => true,
50 _ => false,
51 }
52 }
53 fn cast(syntax: SyntaxToken) -> Option<Self> {
54 if Self::can_cast(syntax.kind()) {
55 Some(Self { syntax })
56 } else {
57 None
58 }
59 }
60 fn syntax(&self) -> &SyntaxToken {
61 &self.syntax
62 }
63}
64#[derive(Debug, Clone, PartialEq, Eq, Hash)]
65pub struct LParen {
66 pub(crate) syntax: SyntaxToken,
67}
68impl std::fmt::Display for LParen {
69 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
70 std::fmt::Display::fmt(&self.syntax, f)
71 }
72}
73impl AstToken for LParen {
74 fn can_cast(kind: SyntaxKind) -> bool {
75 match kind {
76 L_PAREN => true,
77 _ => false,
78 }
79 }
80 fn cast(syntax: SyntaxToken) -> Option<Self> {
81 if Self::can_cast(syntax.kind()) {
82 Some(Self { syntax })
83 } else {
84 None
85 }
86 }
87 fn syntax(&self) -> &SyntaxToken {
88 &self.syntax
89 }
90}
91#[derive(Debug, Clone, PartialEq, Eq, Hash)]
92pub struct RParen {
93 pub(crate) syntax: SyntaxToken,
94}
95impl std::fmt::Display for RParen {
96 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
97 std::fmt::Display::fmt(&self.syntax, f)
98 }
99}
100impl AstToken for RParen {
101 fn can_cast(kind: SyntaxKind) -> bool {
102 match kind {
103 R_PAREN => true,
104 _ => false,
105 }
106 }
107 fn cast(syntax: SyntaxToken) -> Option<Self> {
108 if Self::can_cast(syntax.kind()) {
109 Some(Self { syntax })
110 } else {
111 None
112 }
113 }
114 fn syntax(&self) -> &SyntaxToken {
115 &self.syntax
116 }
117}
118#[derive(Debug, Clone, PartialEq, Eq, Hash)]
119pub struct LCurly {
120 pub(crate) syntax: SyntaxToken,
121}
122impl std::fmt::Display for LCurly {
123 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
124 std::fmt::Display::fmt(&self.syntax, f)
125 }
126}
127impl AstToken for LCurly {
128 fn can_cast(kind: SyntaxKind) -> bool {
129 match kind {
130 L_CURLY => true,
131 _ => false,
132 }
133 }
134 fn cast(syntax: SyntaxToken) -> Option<Self> {
135 if Self::can_cast(syntax.kind()) {
136 Some(Self { syntax })
137 } else {
138 None
139 }
140 }
141 fn syntax(&self) -> &SyntaxToken {
142 &self.syntax
143 }
144}
145#[derive(Debug, Clone, PartialEq, Eq, Hash)]
146pub struct RCurly {
147 pub(crate) syntax: SyntaxToken,
148}
149impl std::fmt::Display for RCurly {
150 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
151 std::fmt::Display::fmt(&self.syntax, f)
152 }
153}
154impl AstToken for RCurly {
155 fn can_cast(kind: SyntaxKind) -> bool {
156 match kind {
157 R_CURLY => true,
158 _ => false,
159 }
160 }
161 fn cast(syntax: SyntaxToken) -> Option<Self> {
162 if Self::can_cast(syntax.kind()) {
163 Some(Self { syntax })
164 } else {
165 None
166 }
167 }
168 fn syntax(&self) -> &SyntaxToken {
169 &self.syntax
170 }
171}
172#[derive(Debug, Clone, PartialEq, Eq, Hash)]
173pub struct LBrack {
174 pub(crate) syntax: SyntaxToken,
175}
176impl std::fmt::Display for LBrack {
177 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
178 std::fmt::Display::fmt(&self.syntax, f)
179 }
180}
181impl AstToken for LBrack {
182 fn can_cast(kind: SyntaxKind) -> bool {
183 match kind {
184 L_BRACK => true,
185 _ => false,
186 }
187 }
188 fn cast(syntax: SyntaxToken) -> Option<Self> {
189 if Self::can_cast(syntax.kind()) {
190 Some(Self { syntax })
191 } else {
192 None
193 }
194 }
195 fn syntax(&self) -> &SyntaxToken {
196 &self.syntax
197 }
198}
199#[derive(Debug, Clone, PartialEq, Eq, Hash)]
200pub struct RBrack {
201 pub(crate) syntax: SyntaxToken,
202}
203impl std::fmt::Display for RBrack {
204 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
205 std::fmt::Display::fmt(&self.syntax, f)
206 }
207}
208impl AstToken for RBrack {
209 fn can_cast(kind: SyntaxKind) -> bool {
210 match kind {
211 R_BRACK => true,
212 _ => false,
213 }
214 }
215 fn cast(syntax: SyntaxToken) -> Option<Self> {
216 if Self::can_cast(syntax.kind()) {
217 Some(Self { syntax })
218 } else {
219 None
220 }
221 }
222 fn syntax(&self) -> &SyntaxToken {
223 &self.syntax
224 }
225}
226#[derive(Debug, Clone, PartialEq, Eq, Hash)]
227pub struct LAngle {
228 pub(crate) syntax: SyntaxToken,
229}
230impl std::fmt::Display for LAngle {
231 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
232 std::fmt::Display::fmt(&self.syntax, f)
233 }
234}
235impl AstToken for LAngle {
236 fn can_cast(kind: SyntaxKind) -> bool {
237 match kind {
238 L_ANGLE => true,
239 _ => false,
240 }
241 }
242 fn cast(syntax: SyntaxToken) -> Option<Self> {
243 if Self::can_cast(syntax.kind()) {
244 Some(Self { syntax })
245 } else {
246 None
247 }
248 }
249 fn syntax(&self) -> &SyntaxToken {
250 &self.syntax
251 }
252}
253#[derive(Debug, Clone, PartialEq, Eq, Hash)]
254pub struct RAngle {
255 pub(crate) syntax: SyntaxToken,
256}
257impl std::fmt::Display for RAngle {
258 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
259 std::fmt::Display::fmt(&self.syntax, f)
260 }
261}
262impl AstToken for RAngle {
263 fn can_cast(kind: SyntaxKind) -> bool {
264 match kind {
265 R_ANGLE => true,
266 _ => false,
267 }
268 }
269 fn cast(syntax: SyntaxToken) -> Option<Self> {
270 if Self::can_cast(syntax.kind()) {
271 Some(Self { syntax })
272 } else {
273 None
274 }
275 }
276 fn syntax(&self) -> &SyntaxToken {
277 &self.syntax
278 }
279}
280#[derive(Debug, Clone, PartialEq, Eq, Hash)]
281pub struct At {
282 pub(crate) syntax: SyntaxToken,
283}
284impl std::fmt::Display for At {
285 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
286 std::fmt::Display::fmt(&self.syntax, f)
287 }
288}
289impl AstToken for At {
290 fn can_cast(kind: SyntaxKind) -> bool {
291 match kind {
292 AT => true,
293 _ => false,
294 }
295 }
296 fn cast(syntax: SyntaxToken) -> Option<Self> {
297 if Self::can_cast(syntax.kind()) {
298 Some(Self { syntax })
299 } else {
300 None
301 }
302 }
303 fn syntax(&self) -> &SyntaxToken {
304 &self.syntax
305 }
306}
307#[derive(Debug, Clone, PartialEq, Eq, Hash)]
308pub struct Pound {
309 pub(crate) syntax: SyntaxToken,
310}
311impl std::fmt::Display for Pound {
312 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
313 std::fmt::Display::fmt(&self.syntax, f)
314 }
315}
316impl AstToken for Pound {
317 fn can_cast(kind: SyntaxKind) -> bool {
318 match kind {
319 POUND => true,
320 _ => false,
321 }
322 }
323 fn cast(syntax: SyntaxToken) -> Option<Self> {
324 if Self::can_cast(syntax.kind()) {
325 Some(Self { syntax })
326 } else {
327 None
328 }
329 }
330 fn syntax(&self) -> &SyntaxToken {
331 &self.syntax
332 }
333}
334#[derive(Debug, Clone, PartialEq, Eq, Hash)]
335pub struct Tilde {
336 pub(crate) syntax: SyntaxToken,
337}
338impl std::fmt::Display for Tilde {
339 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
340 std::fmt::Display::fmt(&self.syntax, f)
341 }
342}
343impl AstToken for Tilde {
344 fn can_cast(kind: SyntaxKind) -> bool {
345 match kind {
346 TILDE => true,
347 _ => false,
348 }
349 }
350 fn cast(syntax: SyntaxToken) -> Option<Self> {
351 if Self::can_cast(syntax.kind()) {
352 Some(Self { syntax })
353 } else {
354 None
355 }
356 }
357 fn syntax(&self) -> &SyntaxToken {
358 &self.syntax
359 }
360}
361#[derive(Debug, Clone, PartialEq, Eq, Hash)]
362pub struct Question {
363 pub(crate) syntax: SyntaxToken,
364}
365impl std::fmt::Display for Question {
366 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
367 std::fmt::Display::fmt(&self.syntax, f)
368 }
369}
370impl AstToken for Question {
371 fn can_cast(kind: SyntaxKind) -> bool {
372 match kind {
373 QUESTION => true,
374 _ => false,
375 }
376 }
377 fn cast(syntax: SyntaxToken) -> Option<Self> {
378 if Self::can_cast(syntax.kind()) {
379 Some(Self { syntax })
380 } else {
381 None
382 }
383 }
384 fn syntax(&self) -> &SyntaxToken {
385 &self.syntax
386 }
387}
388#[derive(Debug, Clone, PartialEq, Eq, Hash)]
389pub struct Dollar {
390 pub(crate) syntax: SyntaxToken,
391}
392impl std::fmt::Display for Dollar {
393 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
394 std::fmt::Display::fmt(&self.syntax, f)
395 }
396}
397impl AstToken for Dollar {
398 fn can_cast(kind: SyntaxKind) -> bool {
399 match kind {
400 DOLLAR => true,
401 _ => false,
402 }
403 }
404 fn cast(syntax: SyntaxToken) -> Option<Self> {
405 if Self::can_cast(syntax.kind()) {
406 Some(Self { syntax })
407 } else {
408 None
409 }
410 }
411 fn syntax(&self) -> &SyntaxToken {
412 &self.syntax
413 }
414}
415#[derive(Debug, Clone, PartialEq, Eq, Hash)]
416pub struct Amp {
417 pub(crate) syntax: SyntaxToken,
418}
419impl std::fmt::Display for Amp {
420 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
421 std::fmt::Display::fmt(&self.syntax, f)
422 }
423}
424impl AstToken for Amp {
425 fn can_cast(kind: SyntaxKind) -> bool {
426 match kind {
427 AMP => true,
428 _ => false,
429 }
430 }
431 fn cast(syntax: SyntaxToken) -> Option<Self> {
432 if Self::can_cast(syntax.kind()) {
433 Some(Self { syntax })
434 } else {
435 None
436 }
437 }
438 fn syntax(&self) -> &SyntaxToken {
439 &self.syntax
440 }
441}
442#[derive(Debug, Clone, PartialEq, Eq, Hash)]
443pub struct Pipe {
444 pub(crate) syntax: SyntaxToken,
445}
446impl std::fmt::Display for Pipe {
447 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
448 std::fmt::Display::fmt(&self.syntax, f)
449 }
450}
451impl AstToken for Pipe {
452 fn can_cast(kind: SyntaxKind) -> bool {
453 match kind {
454 PIPE => true,
455 _ => false,
456 }
457 }
458 fn cast(syntax: SyntaxToken) -> Option<Self> {
459 if Self::can_cast(syntax.kind()) {
460 Some(Self { syntax })
461 } else {
462 None
463 }
464 }
465 fn syntax(&self) -> &SyntaxToken {
466 &self.syntax
467 }
468}
469#[derive(Debug, Clone, PartialEq, Eq, Hash)]
470pub struct Plus {
471 pub(crate) syntax: SyntaxToken,
472}
473impl std::fmt::Display for Plus {
474 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
475 std::fmt::Display::fmt(&self.syntax, f)
476 }
477}
478impl AstToken for Plus {
479 fn can_cast(kind: SyntaxKind) -> bool {
480 match kind {
481 PLUS => true,
482 _ => false,
483 }
484 }
485 fn cast(syntax: SyntaxToken) -> Option<Self> {
486 if Self::can_cast(syntax.kind()) {
487 Some(Self { syntax })
488 } else {
489 None
490 }
491 }
492 fn syntax(&self) -> &SyntaxToken {
493 &self.syntax
494 }
495}
496#[derive(Debug, Clone, PartialEq, Eq, Hash)]
497pub struct Star {
498 pub(crate) syntax: SyntaxToken,
499}
500impl std::fmt::Display for Star {
501 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
502 std::fmt::Display::fmt(&self.syntax, f)
503 }
504}
505impl AstToken for Star {
506 fn can_cast(kind: SyntaxKind) -> bool {
507 match kind {
508 STAR => true,
509 _ => false,
510 }
511 }
512 fn cast(syntax: SyntaxToken) -> Option<Self> {
513 if Self::can_cast(syntax.kind()) {
514 Some(Self { syntax })
515 } else {
516 None
517 }
518 }
519 fn syntax(&self) -> &SyntaxToken {
520 &self.syntax
521 }
522}
523#[derive(Debug, Clone, PartialEq, Eq, Hash)]
524pub struct Slash {
525 pub(crate) syntax: SyntaxToken,
526}
527impl std::fmt::Display for Slash {
528 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
529 std::fmt::Display::fmt(&self.syntax, f)
530 }
531}
532impl AstToken for Slash {
533 fn can_cast(kind: SyntaxKind) -> bool {
534 match kind {
535 SLASH => true,
536 _ => false,
537 }
538 }
539 fn cast(syntax: SyntaxToken) -> Option<Self> {
540 if Self::can_cast(syntax.kind()) {
541 Some(Self { syntax })
542 } else {
543 None
544 }
545 }
546 fn syntax(&self) -> &SyntaxToken {
547 &self.syntax
548 }
549}
550#[derive(Debug, Clone, PartialEq, Eq, Hash)]
551pub struct Caret {
552 pub(crate) syntax: SyntaxToken,
553}
554impl std::fmt::Display for Caret {
555 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
556 std::fmt::Display::fmt(&self.syntax, f)
557 }
558}
559impl AstToken for Caret {
560 fn can_cast(kind: SyntaxKind) -> bool {
561 match kind {
562 CARET => true,
563 _ => false,
564 }
565 }
566 fn cast(syntax: SyntaxToken) -> Option<Self> {
567 if Self::can_cast(syntax.kind()) {
568 Some(Self { syntax })
569 } else {
570 None
571 }
572 }
573 fn syntax(&self) -> &SyntaxToken {
574 &self.syntax
575 }
576}
577#[derive(Debug, Clone, PartialEq, Eq, Hash)]
578pub struct Percent {
579 pub(crate) syntax: SyntaxToken,
580}
581impl std::fmt::Display for Percent {
582 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
583 std::fmt::Display::fmt(&self.syntax, f)
584 }
585}
586impl AstToken for Percent {
587 fn can_cast(kind: SyntaxKind) -> bool {
588 match kind {
589 PERCENT => true,
590 _ => false,
591 }
592 }
593 fn cast(syntax: SyntaxToken) -> Option<Self> {
594 if Self::can_cast(syntax.kind()) {
595 Some(Self { syntax })
596 } else {
597 None
598 }
599 }
600 fn syntax(&self) -> &SyntaxToken {
601 &self.syntax
602 }
603}
604#[derive(Debug, Clone, PartialEq, Eq, Hash)]
605pub struct Underscore {
606 pub(crate) syntax: SyntaxToken,
607}
608impl std::fmt::Display for Underscore {
609 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
610 std::fmt::Display::fmt(&self.syntax, f)
611 }
612}
613impl AstToken for Underscore {
614 fn can_cast(kind: SyntaxKind) -> bool {
615 match kind {
616 UNDERSCORE => true,
617 _ => false,
618 }
619 }
620 fn cast(syntax: SyntaxToken) -> Option<Self> {
621 if Self::can_cast(syntax.kind()) {
622 Some(Self { syntax })
623 } else {
624 None
625 }
626 }
627 fn syntax(&self) -> &SyntaxToken {
628 &self.syntax
629 }
630}
631#[derive(Debug, Clone, PartialEq, Eq, Hash)]
632pub struct Dot {
633 pub(crate) syntax: SyntaxToken,
634}
635impl std::fmt::Display for Dot {
636 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
637 std::fmt::Display::fmt(&self.syntax, f)
638 }
639}
640impl AstToken for Dot {
641 fn can_cast(kind: SyntaxKind) -> bool {
642 match kind {
643 DOT => true,
644 _ => false,
645 }
646 }
647 fn cast(syntax: SyntaxToken) -> Option<Self> {
648 if Self::can_cast(syntax.kind()) {
649 Some(Self { syntax })
650 } else {
651 None
652 }
653 }
654 fn syntax(&self) -> &SyntaxToken {
655 &self.syntax
656 }
657}
658#[derive(Debug, Clone, PartialEq, Eq, Hash)]
659pub struct Dotdot {
660 pub(crate) syntax: SyntaxToken,
661}
662impl std::fmt::Display for Dotdot {
663 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
664 std::fmt::Display::fmt(&self.syntax, f)
665 }
666}
667impl AstToken for Dotdot {
668 fn can_cast(kind: SyntaxKind) -> bool {
669 match kind {
670 DOTDOT => true,
671 _ => false,
672 }
673 }
674 fn cast(syntax: SyntaxToken) -> Option<Self> {
675 if Self::can_cast(syntax.kind()) {
676 Some(Self { syntax })
677 } else {
678 None
679 }
680 }
681 fn syntax(&self) -> &SyntaxToken {
682 &self.syntax
683 }
684}
685#[derive(Debug, Clone, PartialEq, Eq, Hash)]
686pub struct Dotdotdot {
687 pub(crate) syntax: SyntaxToken,
688}
689impl std::fmt::Display for Dotdotdot {
690 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
691 std::fmt::Display::fmt(&self.syntax, f)
692 }
693}
694impl AstToken for Dotdotdot {
695 fn can_cast(kind: SyntaxKind) -> bool {
696 match kind {
697 DOTDOTDOT => true,
698 _ => false,
699 }
700 }
701 fn cast(syntax: SyntaxToken) -> Option<Self> {
702 if Self::can_cast(syntax.kind()) {
703 Some(Self { syntax })
704 } else {
705 None
706 }
707 }
708 fn syntax(&self) -> &SyntaxToken {
709 &self.syntax
710 }
711}
712#[derive(Debug, Clone, PartialEq, Eq, Hash)]
713pub struct Dotdoteq {
714 pub(crate) syntax: SyntaxToken,
715}
716impl std::fmt::Display for Dotdoteq {
717 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
718 std::fmt::Display::fmt(&self.syntax, f)
719 }
720}
721impl AstToken for Dotdoteq {
722 fn can_cast(kind: SyntaxKind) -> bool {
723 match kind {
724 DOTDOTEQ => true,
725 _ => false,
726 }
727 }
728 fn cast(syntax: SyntaxToken) -> Option<Self> {
729 if Self::can_cast(syntax.kind()) {
730 Some(Self { syntax })
731 } else {
732 None
733 }
734 }
735 fn syntax(&self) -> &SyntaxToken {
736 &self.syntax
737 }
738}
739#[derive(Debug, Clone, PartialEq, Eq, Hash)]
740pub struct Colon {
741 pub(crate) syntax: SyntaxToken,
742}
743impl std::fmt::Display for Colon {
744 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
745 std::fmt::Display::fmt(&self.syntax, f)
746 }
747}
748impl AstToken for Colon {
749 fn can_cast(kind: SyntaxKind) -> bool {
750 match kind {
751 COLON => true,
752 _ => false,
753 }
754 }
755 fn cast(syntax: SyntaxToken) -> Option<Self> {
756 if Self::can_cast(syntax.kind()) {
757 Some(Self { syntax })
758 } else {
759 None
760 }
761 }
762 fn syntax(&self) -> &SyntaxToken {
763 &self.syntax
764 }
765}
766#[derive(Debug, Clone, PartialEq, Eq, Hash)]
767pub struct Coloncolon {
768 pub(crate) syntax: SyntaxToken,
769}
770impl std::fmt::Display for Coloncolon {
771 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
772 std::fmt::Display::fmt(&self.syntax, f)
773 }
774}
775impl AstToken for Coloncolon {
776 fn can_cast(kind: SyntaxKind) -> bool {
777 match kind {
778 COLONCOLON => true,
779 _ => false,
780 }
781 }
782 fn cast(syntax: SyntaxToken) -> Option<Self> {
783 if Self::can_cast(syntax.kind()) {
784 Some(Self { syntax })
785 } else {
786 None
787 }
788 }
789 fn syntax(&self) -> &SyntaxToken {
790 &self.syntax
791 }
792}
793#[derive(Debug, Clone, PartialEq, Eq, Hash)]
794pub struct Eq {
795 pub(crate) syntax: SyntaxToken,
796}
797impl std::fmt::Display for Eq {
798 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
799 std::fmt::Display::fmt(&self.syntax, f)
800 }
801}
802impl AstToken for Eq {
803 fn can_cast(kind: SyntaxKind) -> bool {
804 match kind {
805 EQ => true,
806 _ => false,
807 }
808 }
809 fn cast(syntax: SyntaxToken) -> Option<Self> {
810 if Self::can_cast(syntax.kind()) {
811 Some(Self { syntax })
812 } else {
813 None
814 }
815 }
816 fn syntax(&self) -> &SyntaxToken {
817 &self.syntax
818 }
819}
820#[derive(Debug, Clone, PartialEq, Eq, Hash)]
821pub struct Eqeq {
822 pub(crate) syntax: SyntaxToken,
823}
824impl std::fmt::Display for Eqeq {
825 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
826 std::fmt::Display::fmt(&self.syntax, f)
827 }
828}
829impl AstToken for Eqeq {
830 fn can_cast(kind: SyntaxKind) -> bool {
831 match kind {
832 EQEQ => true,
833 _ => false,
834 }
835 }
836 fn cast(syntax: SyntaxToken) -> Option<Self> {
837 if Self::can_cast(syntax.kind()) {
838 Some(Self { syntax })
839 } else {
840 None
841 }
842 }
843 fn syntax(&self) -> &SyntaxToken {
844 &self.syntax
845 }
846}
847#[derive(Debug, Clone, PartialEq, Eq, Hash)]
848pub struct FatArrow {
849 pub(crate) syntax: SyntaxToken,
850}
851impl std::fmt::Display for FatArrow {
852 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
853 std::fmt::Display::fmt(&self.syntax, f)
854 }
855}
856impl AstToken for FatArrow {
857 fn can_cast(kind: SyntaxKind) -> bool {
858 match kind {
859 FAT_ARROW => true,
860 _ => false,
861 }
862 }
863 fn cast(syntax: SyntaxToken) -> Option<Self> {
864 if Self::can_cast(syntax.kind()) {
865 Some(Self { syntax })
866 } else {
867 None
868 }
869 }
870 fn syntax(&self) -> &SyntaxToken {
871 &self.syntax
872 }
873}
874#[derive(Debug, Clone, PartialEq, Eq, Hash)]
875pub struct Excl {
876 pub(crate) syntax: SyntaxToken,
877}
878impl std::fmt::Display for Excl {
879 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
880 std::fmt::Display::fmt(&self.syntax, f)
881 }
882}
883impl AstToken for Excl {
884 fn can_cast(kind: SyntaxKind) -> bool {
885 match kind {
886 EXCL => true,
887 _ => false,
888 }
889 }
890 fn cast(syntax: SyntaxToken) -> Option<Self> {
891 if Self::can_cast(syntax.kind()) {
892 Some(Self { syntax })
893 } else {
894 None
895 }
896 }
897 fn syntax(&self) -> &SyntaxToken {
898 &self.syntax
899 }
900}
901#[derive(Debug, Clone, PartialEq, Eq, Hash)]
902pub struct Neq {
903 pub(crate) syntax: SyntaxToken,
904}
905impl std::fmt::Display for Neq {
906 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
907 std::fmt::Display::fmt(&self.syntax, f)
908 }
909}
910impl AstToken for Neq {
911 fn can_cast(kind: SyntaxKind) -> bool {
912 match kind {
913 NEQ => true,
914 _ => false,
915 }
916 }
917 fn cast(syntax: SyntaxToken) -> Option<Self> {
918 if Self::can_cast(syntax.kind()) {
919 Some(Self { syntax })
920 } else {
921 None
922 }
923 }
924 fn syntax(&self) -> &SyntaxToken {
925 &self.syntax
926 }
927}
928#[derive(Debug, Clone, PartialEq, Eq, Hash)]
929pub struct Minus {
930 pub(crate) syntax: SyntaxToken,
931}
932impl std::fmt::Display for Minus {
933 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
934 std::fmt::Display::fmt(&self.syntax, f)
935 }
936}
937impl AstToken for Minus {
938 fn can_cast(kind: SyntaxKind) -> bool {
939 match kind {
940 MINUS => true,
941 _ => false,
942 }
943 }
944 fn cast(syntax: SyntaxToken) -> Option<Self> {
945 if Self::can_cast(syntax.kind()) {
946 Some(Self { syntax })
947 } else {
948 None
949 }
950 }
951 fn syntax(&self) -> &SyntaxToken {
952 &self.syntax
953 }
954}
955#[derive(Debug, Clone, PartialEq, Eq, Hash)]
956pub struct ThinArrow {
957 pub(crate) syntax: SyntaxToken,
958}
959impl std::fmt::Display for ThinArrow {
960 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
961 std::fmt::Display::fmt(&self.syntax, f)
962 }
963}
964impl AstToken for ThinArrow {
965 fn can_cast(kind: SyntaxKind) -> bool {
966 match kind {
967 THIN_ARROW => true,
968 _ => false,
969 }
970 }
971 fn cast(syntax: SyntaxToken) -> Option<Self> {
972 if Self::can_cast(syntax.kind()) {
973 Some(Self { syntax })
974 } else {
975 None
976 }
977 }
978 fn syntax(&self) -> &SyntaxToken {
979 &self.syntax
980 }
981}
982#[derive(Debug, Clone, PartialEq, Eq, Hash)]
983pub struct Lteq {
984 pub(crate) syntax: SyntaxToken,
985}
986impl std::fmt::Display for Lteq {
987 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
988 std::fmt::Display::fmt(&self.syntax, f)
989 }
990}
991impl AstToken for Lteq {
992 fn can_cast(kind: SyntaxKind) -> bool {
993 match kind {
994 LTEQ => true,
995 _ => false,
996 }
997 }
998 fn cast(syntax: SyntaxToken) -> Option<Self> {
999 if Self::can_cast(syntax.kind()) {
1000 Some(Self { syntax })
1001 } else {
1002 None
1003 }
1004 }
1005 fn syntax(&self) -> &SyntaxToken {
1006 &self.syntax
1007 }
1008}
1009#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1010pub struct Gteq {
1011 pub(crate) syntax: SyntaxToken,
1012}
1013impl std::fmt::Display for Gteq {
1014 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1015 std::fmt::Display::fmt(&self.syntax, f)
1016 }
1017}
1018impl AstToken for Gteq {
1019 fn can_cast(kind: SyntaxKind) -> bool {
1020 match kind {
1021 GTEQ => true,
1022 _ => false,
1023 }
1024 }
1025 fn cast(syntax: SyntaxToken) -> Option<Self> {
1026 if Self::can_cast(syntax.kind()) {
1027 Some(Self { syntax })
1028 } else {
1029 None
1030 }
1031 }
1032 fn syntax(&self) -> &SyntaxToken {
1033 &self.syntax
1034 }
1035}
1036#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1037pub struct Pluseq {
1038 pub(crate) syntax: SyntaxToken,
1039}
1040impl std::fmt::Display for Pluseq {
1041 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1042 std::fmt::Display::fmt(&self.syntax, f)
1043 }
1044}
1045impl AstToken for Pluseq {
1046 fn can_cast(kind: SyntaxKind) -> bool {
1047 match kind {
1048 PLUSEQ => true,
1049 _ => false,
1050 }
1051 }
1052 fn cast(syntax: SyntaxToken) -> Option<Self> {
1053 if Self::can_cast(syntax.kind()) {
1054 Some(Self { syntax })
1055 } else {
1056 None
1057 }
1058 }
1059 fn syntax(&self) -> &SyntaxToken {
1060 &self.syntax
1061 }
1062}
1063#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1064pub struct Minuseq {
1065 pub(crate) syntax: SyntaxToken,
1066}
1067impl std::fmt::Display for Minuseq {
1068 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1069 std::fmt::Display::fmt(&self.syntax, f)
1070 }
1071}
1072impl AstToken for Minuseq {
1073 fn can_cast(kind: SyntaxKind) -> bool {
1074 match kind {
1075 MINUSEQ => true,
1076 _ => false,
1077 }
1078 }
1079 fn cast(syntax: SyntaxToken) -> Option<Self> {
1080 if Self::can_cast(syntax.kind()) {
1081 Some(Self { syntax })
1082 } else {
1083 None
1084 }
1085 }
1086 fn syntax(&self) -> &SyntaxToken {
1087 &self.syntax
1088 }
1089}
1090#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1091pub struct Pipeeq {
1092 pub(crate) syntax: SyntaxToken,
1093}
1094impl std::fmt::Display for Pipeeq {
1095 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1096 std::fmt::Display::fmt(&self.syntax, f)
1097 }
1098}
1099impl AstToken for Pipeeq {
1100 fn can_cast(kind: SyntaxKind) -> bool {
1101 match kind {
1102 PIPEEQ => true,
1103 _ => false,
1104 }
1105 }
1106 fn cast(syntax: SyntaxToken) -> Option<Self> {
1107 if Self::can_cast(syntax.kind()) {
1108 Some(Self { syntax })
1109 } else {
1110 None
1111 }
1112 }
1113 fn syntax(&self) -> &SyntaxToken {
1114 &self.syntax
1115 }
1116}
1117#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1118pub struct Ampeq {
1119 pub(crate) syntax: SyntaxToken,
1120}
1121impl std::fmt::Display for Ampeq {
1122 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1123 std::fmt::Display::fmt(&self.syntax, f)
1124 }
1125}
1126impl AstToken for Ampeq {
1127 fn can_cast(kind: SyntaxKind) -> bool {
1128 match kind {
1129 AMPEQ => true,
1130 _ => false,
1131 }
1132 }
1133 fn cast(syntax: SyntaxToken) -> Option<Self> {
1134 if Self::can_cast(syntax.kind()) {
1135 Some(Self { syntax })
1136 } else {
1137 None
1138 }
1139 }
1140 fn syntax(&self) -> &SyntaxToken {
1141 &self.syntax
1142 }
1143}
1144#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1145pub struct Careteq {
1146 pub(crate) syntax: SyntaxToken,
1147}
1148impl std::fmt::Display for Careteq {
1149 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1150 std::fmt::Display::fmt(&self.syntax, f)
1151 }
1152}
1153impl AstToken for Careteq {
1154 fn can_cast(kind: SyntaxKind) -> bool {
1155 match kind {
1156 CARETEQ => true,
1157 _ => false,
1158 }
1159 }
1160 fn cast(syntax: SyntaxToken) -> Option<Self> {
1161 if Self::can_cast(syntax.kind()) {
1162 Some(Self { syntax })
1163 } else {
1164 None
1165 }
1166 }
1167 fn syntax(&self) -> &SyntaxToken {
1168 &self.syntax
1169 }
1170}
1171#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1172pub struct Slasheq {
1173 pub(crate) syntax: SyntaxToken,
1174}
1175impl std::fmt::Display for Slasheq {
1176 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1177 std::fmt::Display::fmt(&self.syntax, f)
1178 }
1179}
1180impl AstToken for Slasheq {
1181 fn can_cast(kind: SyntaxKind) -> bool {
1182 match kind {
1183 SLASHEQ => true,
1184 _ => false,
1185 }
1186 }
1187 fn cast(syntax: SyntaxToken) -> Option<Self> {
1188 if Self::can_cast(syntax.kind()) {
1189 Some(Self { syntax })
1190 } else {
1191 None
1192 }
1193 }
1194 fn syntax(&self) -> &SyntaxToken {
1195 &self.syntax
1196 }
1197}
1198#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1199pub struct Stareq {
1200 pub(crate) syntax: SyntaxToken,
1201}
1202impl std::fmt::Display for Stareq {
1203 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1204 std::fmt::Display::fmt(&self.syntax, f)
1205 }
1206}
1207impl AstToken for Stareq {
1208 fn can_cast(kind: SyntaxKind) -> bool {
1209 match kind {
1210 STAREQ => true,
1211 _ => false,
1212 }
1213 }
1214 fn cast(syntax: SyntaxToken) -> Option<Self> {
1215 if Self::can_cast(syntax.kind()) {
1216 Some(Self { syntax })
1217 } else {
1218 None
1219 }
1220 }
1221 fn syntax(&self) -> &SyntaxToken {
1222 &self.syntax
1223 }
1224}
1225#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1226pub struct Percenteq {
1227 pub(crate) syntax: SyntaxToken,
1228}
1229impl std::fmt::Display for Percenteq {
1230 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1231 std::fmt::Display::fmt(&self.syntax, f)
1232 }
1233}
1234impl AstToken for Percenteq {
1235 fn can_cast(kind: SyntaxKind) -> bool {
1236 match kind {
1237 PERCENTEQ => true,
1238 _ => false,
1239 }
1240 }
1241 fn cast(syntax: SyntaxToken) -> Option<Self> {
1242 if Self::can_cast(syntax.kind()) {
1243 Some(Self { syntax })
1244 } else {
1245 None
1246 }
1247 }
1248 fn syntax(&self) -> &SyntaxToken {
1249 &self.syntax
1250 }
1251}
1252#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1253pub struct Ampamp {
1254 pub(crate) syntax: SyntaxToken,
1255}
1256impl std::fmt::Display for Ampamp {
1257 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1258 std::fmt::Display::fmt(&self.syntax, f)
1259 }
1260}
1261impl AstToken for Ampamp {
1262 fn can_cast(kind: SyntaxKind) -> bool {
1263 match kind {
1264 AMPAMP => true,
1265 _ => false,
1266 }
1267 }
1268 fn cast(syntax: SyntaxToken) -> Option<Self> {
1269 if Self::can_cast(syntax.kind()) {
1270 Some(Self { syntax })
1271 } else {
1272 None
1273 }
1274 }
1275 fn syntax(&self) -> &SyntaxToken {
1276 &self.syntax
1277 }
1278}
1279#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1280pub struct Pipepipe {
1281 pub(crate) syntax: SyntaxToken,
1282}
1283impl std::fmt::Display for Pipepipe {
1284 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1285 std::fmt::Display::fmt(&self.syntax, f)
1286 }
1287}
1288impl AstToken for Pipepipe {
1289 fn can_cast(kind: SyntaxKind) -> bool {
1290 match kind {
1291 PIPEPIPE => true,
1292 _ => false,
1293 }
1294 }
1295 fn cast(syntax: SyntaxToken) -> Option<Self> {
1296 if Self::can_cast(syntax.kind()) {
1297 Some(Self { syntax })
1298 } else {
1299 None
1300 }
1301 }
1302 fn syntax(&self) -> &SyntaxToken {
1303 &self.syntax
1304 }
1305}
1306#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1307pub struct Shl {
1308 pub(crate) syntax: SyntaxToken,
1309}
1310impl std::fmt::Display for Shl {
1311 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1312 std::fmt::Display::fmt(&self.syntax, f)
1313 }
1314}
1315impl AstToken for Shl {
1316 fn can_cast(kind: SyntaxKind) -> bool {
1317 match kind {
1318 SHL => true,
1319 _ => false,
1320 }
1321 }
1322 fn cast(syntax: SyntaxToken) -> Option<Self> {
1323 if Self::can_cast(syntax.kind()) {
1324 Some(Self { syntax })
1325 } else {
1326 None
1327 }
1328 }
1329 fn syntax(&self) -> &SyntaxToken {
1330 &self.syntax
1331 }
1332}
1333#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1334pub struct Shr {
1335 pub(crate) syntax: SyntaxToken,
1336}
1337impl std::fmt::Display for Shr {
1338 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1339 std::fmt::Display::fmt(&self.syntax, f)
1340 }
1341}
1342impl AstToken for Shr {
1343 fn can_cast(kind: SyntaxKind) -> bool {
1344 match kind {
1345 SHR => true,
1346 _ => false,
1347 }
1348 }
1349 fn cast(syntax: SyntaxToken) -> Option<Self> {
1350 if Self::can_cast(syntax.kind()) {
1351 Some(Self { syntax })
1352 } else {
1353 None
1354 }
1355 }
1356 fn syntax(&self) -> &SyntaxToken {
1357 &self.syntax
1358 }
1359}
1360#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1361pub struct Shleq {
1362 pub(crate) syntax: SyntaxToken,
1363}
1364impl std::fmt::Display for Shleq {
1365 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1366 std::fmt::Display::fmt(&self.syntax, f)
1367 }
1368}
1369impl AstToken for Shleq {
1370 fn can_cast(kind: SyntaxKind) -> bool {
1371 match kind {
1372 SHLEQ => true,
1373 _ => false,
1374 }
1375 }
1376 fn cast(syntax: SyntaxToken) -> Option<Self> {
1377 if Self::can_cast(syntax.kind()) {
1378 Some(Self { syntax })
1379 } else {
1380 None
1381 }
1382 }
1383 fn syntax(&self) -> &SyntaxToken {
1384 &self.syntax
1385 }
1386}
1387#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1388pub struct Shreq {
1389 pub(crate) syntax: SyntaxToken,
1390}
1391impl std::fmt::Display for Shreq {
1392 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1393 std::fmt::Display::fmt(&self.syntax, f)
1394 }
1395}
1396impl AstToken for Shreq {
1397 fn can_cast(kind: SyntaxKind) -> bool {
1398 match kind {
1399 SHREQ => true,
1400 _ => false,
1401 }
1402 }
1403 fn cast(syntax: SyntaxToken) -> Option<Self> {
1404 if Self::can_cast(syntax.kind()) {
1405 Some(Self { syntax })
1406 } else {
1407 None
1408 }
1409 }
1410 fn syntax(&self) -> &SyntaxToken {
1411 &self.syntax
1412 }
1413}
1414#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1415pub struct AsKw {
1416 pub(crate) syntax: SyntaxToken,
1417}
1418impl std::fmt::Display for AsKw {
1419 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1420 std::fmt::Display::fmt(&self.syntax, f)
1421 }
1422}
1423impl AstToken for AsKw {
1424 fn can_cast(kind: SyntaxKind) -> bool {
1425 match kind {
1426 AS_KW => true,
1427 _ => false,
1428 }
1429 }
1430 fn cast(syntax: SyntaxToken) -> Option<Self> {
1431 if Self::can_cast(syntax.kind()) {
1432 Some(Self { syntax })
1433 } else {
1434 None
1435 }
1436 }
1437 fn syntax(&self) -> &SyntaxToken {
1438 &self.syntax
1439 }
1440}
1441#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1442pub struct AsyncKw {
1443 pub(crate) syntax: SyntaxToken,
1444}
1445impl std::fmt::Display for AsyncKw {
1446 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1447 std::fmt::Display::fmt(&self.syntax, f)
1448 }
1449}
1450impl AstToken for AsyncKw {
1451 fn can_cast(kind: SyntaxKind) -> bool {
1452 match kind {
1453 ASYNC_KW => true,
1454 _ => false,
1455 }
1456 }
1457 fn cast(syntax: SyntaxToken) -> Option<Self> {
1458 if Self::can_cast(syntax.kind()) {
1459 Some(Self { syntax })
1460 } else {
1461 None
1462 }
1463 }
1464 fn syntax(&self) -> &SyntaxToken {
1465 &self.syntax
1466 }
1467}
1468#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1469pub struct AwaitKw {
1470 pub(crate) syntax: SyntaxToken,
1471}
1472impl std::fmt::Display for AwaitKw {
1473 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1474 std::fmt::Display::fmt(&self.syntax, f)
1475 }
1476}
1477impl AstToken for AwaitKw {
1478 fn can_cast(kind: SyntaxKind) -> bool {
1479 match kind {
1480 AWAIT_KW => true,
1481 _ => false,
1482 }
1483 }
1484 fn cast(syntax: SyntaxToken) -> Option<Self> {
1485 if Self::can_cast(syntax.kind()) {
1486 Some(Self { syntax })
1487 } else {
1488 None
1489 }
1490 }
1491 fn syntax(&self) -> &SyntaxToken {
1492 &self.syntax
1493 }
1494}
1495#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1496pub struct BoxKw {
1497 pub(crate) syntax: SyntaxToken,
1498}
1499impl std::fmt::Display for BoxKw {
1500 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1501 std::fmt::Display::fmt(&self.syntax, f)
1502 }
1503}
1504impl AstToken for BoxKw {
1505 fn can_cast(kind: SyntaxKind) -> bool {
1506 match kind {
1507 BOX_KW => true,
1508 _ => false,
1509 }
1510 }
1511 fn cast(syntax: SyntaxToken) -> Option<Self> {
1512 if Self::can_cast(syntax.kind()) {
1513 Some(Self { syntax })
1514 } else {
1515 None
1516 }
1517 }
1518 fn syntax(&self) -> &SyntaxToken {
1519 &self.syntax
1520 }
1521}
1522#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1523pub struct BreakKw {
1524 pub(crate) syntax: SyntaxToken,
1525}
1526impl std::fmt::Display for BreakKw {
1527 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1528 std::fmt::Display::fmt(&self.syntax, f)
1529 }
1530}
1531impl AstToken for BreakKw {
1532 fn can_cast(kind: SyntaxKind) -> bool {
1533 match kind {
1534 BREAK_KW => true,
1535 _ => false,
1536 }
1537 }
1538 fn cast(syntax: SyntaxToken) -> Option<Self> {
1539 if Self::can_cast(syntax.kind()) {
1540 Some(Self { syntax })
1541 } else {
1542 None
1543 }
1544 }
1545 fn syntax(&self) -> &SyntaxToken {
1546 &self.syntax
1547 }
1548}
1549#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1550pub struct ConstKw {
1551 pub(crate) syntax: SyntaxToken,
1552}
1553impl std::fmt::Display for ConstKw {
1554 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1555 std::fmt::Display::fmt(&self.syntax, f)
1556 }
1557}
1558impl AstToken for ConstKw {
1559 fn can_cast(kind: SyntaxKind) -> bool {
1560 match kind {
1561 CONST_KW => true,
1562 _ => false,
1563 }
1564 }
1565 fn cast(syntax: SyntaxToken) -> Option<Self> {
1566 if Self::can_cast(syntax.kind()) {
1567 Some(Self { syntax })
1568 } else {
1569 None
1570 }
1571 }
1572 fn syntax(&self) -> &SyntaxToken {
1573 &self.syntax
1574 }
1575}
1576#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1577pub struct ContinueKw {
1578 pub(crate) syntax: SyntaxToken,
1579}
1580impl std::fmt::Display for ContinueKw {
1581 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1582 std::fmt::Display::fmt(&self.syntax, f)
1583 }
1584}
1585impl AstToken for ContinueKw {
1586 fn can_cast(kind: SyntaxKind) -> bool {
1587 match kind {
1588 CONTINUE_KW => true,
1589 _ => false,
1590 }
1591 }
1592 fn cast(syntax: SyntaxToken) -> Option<Self> {
1593 if Self::can_cast(syntax.kind()) {
1594 Some(Self { syntax })
1595 } else {
1596 None
1597 }
1598 }
1599 fn syntax(&self) -> &SyntaxToken {
1600 &self.syntax
1601 }
1602}
1603#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1604pub struct CrateKw {
1605 pub(crate) syntax: SyntaxToken,
1606}
1607impl std::fmt::Display for CrateKw {
1608 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1609 std::fmt::Display::fmt(&self.syntax, f)
1610 }
1611}
1612impl AstToken for CrateKw {
1613 fn can_cast(kind: SyntaxKind) -> bool {
1614 match kind {
1615 CRATE_KW => true,
1616 _ => false,
1617 }
1618 }
1619 fn cast(syntax: SyntaxToken) -> Option<Self> {
1620 if Self::can_cast(syntax.kind()) {
1621 Some(Self { syntax })
1622 } else {
1623 None
1624 }
1625 }
1626 fn syntax(&self) -> &SyntaxToken {
1627 &self.syntax
1628 }
1629}
1630#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1631pub struct DynKw {
1632 pub(crate) syntax: SyntaxToken,
1633}
1634impl std::fmt::Display for DynKw {
1635 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1636 std::fmt::Display::fmt(&self.syntax, f)
1637 }
1638}
1639impl AstToken for DynKw {
1640 fn can_cast(kind: SyntaxKind) -> bool {
1641 match kind {
1642 DYN_KW => true,
1643 _ => false,
1644 }
1645 }
1646 fn cast(syntax: SyntaxToken) -> Option<Self> {
1647 if Self::can_cast(syntax.kind()) {
1648 Some(Self { syntax })
1649 } else {
1650 None
1651 }
1652 }
1653 fn syntax(&self) -> &SyntaxToken {
1654 &self.syntax
1655 }
1656}
1657#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1658pub struct ElseKw {
1659 pub(crate) syntax: SyntaxToken,
1660}
1661impl std::fmt::Display for ElseKw {
1662 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1663 std::fmt::Display::fmt(&self.syntax, f)
1664 }
1665}
1666impl AstToken for ElseKw {
1667 fn can_cast(kind: SyntaxKind) -> bool {
1668 match kind {
1669 ELSE_KW => true,
1670 _ => false,
1671 }
1672 }
1673 fn cast(syntax: SyntaxToken) -> Option<Self> {
1674 if Self::can_cast(syntax.kind()) {
1675 Some(Self { syntax })
1676 } else {
1677 None
1678 }
1679 }
1680 fn syntax(&self) -> &SyntaxToken {
1681 &self.syntax
1682 }
1683}
1684#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1685pub struct EnumKw {
1686 pub(crate) syntax: SyntaxToken,
1687}
1688impl std::fmt::Display for EnumKw {
1689 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1690 std::fmt::Display::fmt(&self.syntax, f)
1691 }
1692}
1693impl AstToken for EnumKw {
1694 fn can_cast(kind: SyntaxKind) -> bool {
1695 match kind {
1696 ENUM_KW => true,
1697 _ => false,
1698 }
1699 }
1700 fn cast(syntax: SyntaxToken) -> Option<Self> {
1701 if Self::can_cast(syntax.kind()) {
1702 Some(Self { syntax })
1703 } else {
1704 None
1705 }
1706 }
1707 fn syntax(&self) -> &SyntaxToken {
1708 &self.syntax
1709 }
1710}
1711#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1712pub struct ExternKw {
1713 pub(crate) syntax: SyntaxToken,
1714}
1715impl std::fmt::Display for ExternKw {
1716 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1717 std::fmt::Display::fmt(&self.syntax, f)
1718 }
1719}
1720impl AstToken for ExternKw {
1721 fn can_cast(kind: SyntaxKind) -> bool {
1722 match kind {
1723 EXTERN_KW => true,
1724 _ => false,
1725 }
1726 }
1727 fn cast(syntax: SyntaxToken) -> Option<Self> {
1728 if Self::can_cast(syntax.kind()) {
1729 Some(Self { syntax })
1730 } else {
1731 None
1732 }
1733 }
1734 fn syntax(&self) -> &SyntaxToken {
1735 &self.syntax
1736 }
1737}
1738#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1739pub struct FalseKw {
1740 pub(crate) syntax: SyntaxToken,
1741}
1742impl std::fmt::Display for FalseKw {
1743 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1744 std::fmt::Display::fmt(&self.syntax, f)
1745 }
1746}
1747impl AstToken for FalseKw {
1748 fn can_cast(kind: SyntaxKind) -> bool {
1749 match kind {
1750 FALSE_KW => true,
1751 _ => false,
1752 }
1753 }
1754 fn cast(syntax: SyntaxToken) -> Option<Self> {
1755 if Self::can_cast(syntax.kind()) {
1756 Some(Self { syntax })
1757 } else {
1758 None
1759 }
1760 }
1761 fn syntax(&self) -> &SyntaxToken {
1762 &self.syntax
1763 }
1764}
1765#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1766pub struct FnKw {
1767 pub(crate) syntax: SyntaxToken,
1768}
1769impl std::fmt::Display for FnKw {
1770 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1771 std::fmt::Display::fmt(&self.syntax, f)
1772 }
1773}
1774impl AstToken for FnKw {
1775 fn can_cast(kind: SyntaxKind) -> bool {
1776 match kind {
1777 FN_KW => true,
1778 _ => false,
1779 }
1780 }
1781 fn cast(syntax: SyntaxToken) -> Option<Self> {
1782 if Self::can_cast(syntax.kind()) {
1783 Some(Self { syntax })
1784 } else {
1785 None
1786 }
1787 }
1788 fn syntax(&self) -> &SyntaxToken {
1789 &self.syntax
1790 }
1791}
1792#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1793pub struct ForKw {
1794 pub(crate) syntax: SyntaxToken,
1795}
1796impl std::fmt::Display for ForKw {
1797 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1798 std::fmt::Display::fmt(&self.syntax, f)
1799 }
1800}
1801impl AstToken for ForKw {
1802 fn can_cast(kind: SyntaxKind) -> bool {
1803 match kind {
1804 FOR_KW => true,
1805 _ => false,
1806 }
1807 }
1808 fn cast(syntax: SyntaxToken) -> Option<Self> {
1809 if Self::can_cast(syntax.kind()) {
1810 Some(Self { syntax })
1811 } else {
1812 None
1813 }
1814 }
1815 fn syntax(&self) -> &SyntaxToken {
1816 &self.syntax
1817 }
1818}
1819#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1820pub struct IfKw {
1821 pub(crate) syntax: SyntaxToken,
1822}
1823impl std::fmt::Display for IfKw {
1824 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1825 std::fmt::Display::fmt(&self.syntax, f)
1826 }
1827}
1828impl AstToken for IfKw {
1829 fn can_cast(kind: SyntaxKind) -> bool {
1830 match kind {
1831 IF_KW => true,
1832 _ => false,
1833 }
1834 }
1835 fn cast(syntax: SyntaxToken) -> Option<Self> {
1836 if Self::can_cast(syntax.kind()) {
1837 Some(Self { syntax })
1838 } else {
1839 None
1840 }
1841 }
1842 fn syntax(&self) -> &SyntaxToken {
1843 &self.syntax
1844 }
1845}
1846#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1847pub struct ImplKw {
1848 pub(crate) syntax: SyntaxToken,
1849}
1850impl std::fmt::Display for ImplKw {
1851 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1852 std::fmt::Display::fmt(&self.syntax, f)
1853 }
1854}
1855impl AstToken for ImplKw {
1856 fn can_cast(kind: SyntaxKind) -> bool {
1857 match kind {
1858 IMPL_KW => true,
1859 _ => false,
1860 }
1861 }
1862 fn cast(syntax: SyntaxToken) -> Option<Self> {
1863 if Self::can_cast(syntax.kind()) {
1864 Some(Self { syntax })
1865 } else {
1866 None
1867 }
1868 }
1869 fn syntax(&self) -> &SyntaxToken {
1870 &self.syntax
1871 }
1872}
1873#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1874pub struct InKw {
1875 pub(crate) syntax: SyntaxToken,
1876}
1877impl std::fmt::Display for InKw {
1878 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1879 std::fmt::Display::fmt(&self.syntax, f)
1880 }
1881}
1882impl AstToken for InKw {
1883 fn can_cast(kind: SyntaxKind) -> bool {
1884 match kind {
1885 IN_KW => true,
1886 _ => false,
1887 }
1888 }
1889 fn cast(syntax: SyntaxToken) -> Option<Self> {
1890 if Self::can_cast(syntax.kind()) {
1891 Some(Self { syntax })
1892 } else {
1893 None
1894 }
1895 }
1896 fn syntax(&self) -> &SyntaxToken {
1897 &self.syntax
1898 }
1899}
1900#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1901pub struct LetKw {
1902 pub(crate) syntax: SyntaxToken,
1903}
1904impl std::fmt::Display for LetKw {
1905 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1906 std::fmt::Display::fmt(&self.syntax, f)
1907 }
1908}
1909impl AstToken for LetKw {
1910 fn can_cast(kind: SyntaxKind) -> bool {
1911 match kind {
1912 LET_KW => true,
1913 _ => false,
1914 }
1915 }
1916 fn cast(syntax: SyntaxToken) -> Option<Self> {
1917 if Self::can_cast(syntax.kind()) {
1918 Some(Self { syntax })
1919 } else {
1920 None
1921 }
1922 }
1923 fn syntax(&self) -> &SyntaxToken {
1924 &self.syntax
1925 }
1926}
1927#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1928pub struct LoopKw {
1929 pub(crate) syntax: SyntaxToken,
1930}
1931impl std::fmt::Display for LoopKw {
1932 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1933 std::fmt::Display::fmt(&self.syntax, f)
1934 }
1935}
1936impl AstToken for LoopKw {
1937 fn can_cast(kind: SyntaxKind) -> bool {
1938 match kind {
1939 LOOP_KW => true,
1940 _ => false,
1941 }
1942 }
1943 fn cast(syntax: SyntaxToken) -> Option<Self> {
1944 if Self::can_cast(syntax.kind()) {
1945 Some(Self { syntax })
1946 } else {
1947 None
1948 }
1949 }
1950 fn syntax(&self) -> &SyntaxToken {
1951 &self.syntax
1952 }
1953}
1954#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1955pub struct MacroKw {
1956 pub(crate) syntax: SyntaxToken,
1957}
1958impl std::fmt::Display for MacroKw {
1959 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1960 std::fmt::Display::fmt(&self.syntax, f)
1961 }
1962}
1963impl AstToken for MacroKw {
1964 fn can_cast(kind: SyntaxKind) -> bool {
1965 match kind {
1966 MACRO_KW => true,
1967 _ => false,
1968 }
1969 }
1970 fn cast(syntax: SyntaxToken) -> Option<Self> {
1971 if Self::can_cast(syntax.kind()) {
1972 Some(Self { syntax })
1973 } else {
1974 None
1975 }
1976 }
1977 fn syntax(&self) -> &SyntaxToken {
1978 &self.syntax
1979 }
1980}
1981#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1982pub struct MatchKw {
1983 pub(crate) syntax: SyntaxToken,
1984}
1985impl std::fmt::Display for MatchKw {
1986 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1987 std::fmt::Display::fmt(&self.syntax, f)
1988 }
1989}
1990impl AstToken for MatchKw {
1991 fn can_cast(kind: SyntaxKind) -> bool {
1992 match kind {
1993 MATCH_KW => true,
1994 _ => false,
1995 }
1996 }
1997 fn cast(syntax: SyntaxToken) -> Option<Self> {
1998 if Self::can_cast(syntax.kind()) {
1999 Some(Self { syntax })
2000 } else {
2001 None
2002 }
2003 }
2004 fn syntax(&self) -> &SyntaxToken {
2005 &self.syntax
2006 }
2007}
2008#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2009pub struct ModKw {
2010 pub(crate) syntax: SyntaxToken,
2011}
2012impl std::fmt::Display for ModKw {
2013 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2014 std::fmt::Display::fmt(&self.syntax, f)
2015 }
2016}
2017impl AstToken for ModKw {
2018 fn can_cast(kind: SyntaxKind) -> bool {
2019 match kind {
2020 MOD_KW => true,
2021 _ => false,
2022 }
2023 }
2024 fn cast(syntax: SyntaxToken) -> Option<Self> {
2025 if Self::can_cast(syntax.kind()) {
2026 Some(Self { syntax })
2027 } else {
2028 None
2029 }
2030 }
2031 fn syntax(&self) -> &SyntaxToken {
2032 &self.syntax
2033 }
2034}
2035#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2036pub struct MoveKw {
2037 pub(crate) syntax: SyntaxToken,
2038}
2039impl std::fmt::Display for MoveKw {
2040 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2041 std::fmt::Display::fmt(&self.syntax, f)
2042 }
2043}
2044impl AstToken for MoveKw {
2045 fn can_cast(kind: SyntaxKind) -> bool {
2046 match kind {
2047 MOVE_KW => true,
2048 _ => false,
2049 }
2050 }
2051 fn cast(syntax: SyntaxToken) -> Option<Self> {
2052 if Self::can_cast(syntax.kind()) {
2053 Some(Self { syntax })
2054 } else {
2055 None
2056 }
2057 }
2058 fn syntax(&self) -> &SyntaxToken {
2059 &self.syntax
2060 }
2061}
2062#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2063pub struct MutKw {
2064 pub(crate) syntax: SyntaxToken,
2065}
2066impl std::fmt::Display for MutKw {
2067 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2068 std::fmt::Display::fmt(&self.syntax, f)
2069 }
2070}
2071impl AstToken for MutKw {
2072 fn can_cast(kind: SyntaxKind) -> bool {
2073 match kind {
2074 MUT_KW => true,
2075 _ => false,
2076 }
2077 }
2078 fn cast(syntax: SyntaxToken) -> Option<Self> {
2079 if Self::can_cast(syntax.kind()) {
2080 Some(Self { syntax })
2081 } else {
2082 None
2083 }
2084 }
2085 fn syntax(&self) -> &SyntaxToken {
2086 &self.syntax
2087 }
2088}
2089#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2090pub struct PubKw {
2091 pub(crate) syntax: SyntaxToken,
2092}
2093impl std::fmt::Display for PubKw {
2094 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2095 std::fmt::Display::fmt(&self.syntax, f)
2096 }
2097}
2098impl AstToken for PubKw {
2099 fn can_cast(kind: SyntaxKind) -> bool {
2100 match kind {
2101 PUB_KW => true,
2102 _ => false,
2103 }
2104 }
2105 fn cast(syntax: SyntaxToken) -> Option<Self> {
2106 if Self::can_cast(syntax.kind()) {
2107 Some(Self { syntax })
2108 } else {
2109 None
2110 }
2111 }
2112 fn syntax(&self) -> &SyntaxToken {
2113 &self.syntax
2114 }
2115}
2116#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2117pub struct RefKw {
2118 pub(crate) syntax: SyntaxToken,
2119}
2120impl std::fmt::Display for RefKw {
2121 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2122 std::fmt::Display::fmt(&self.syntax, f)
2123 }
2124}
2125impl AstToken for RefKw {
2126 fn can_cast(kind: SyntaxKind) -> bool {
2127 match kind {
2128 REF_KW => true,
2129 _ => false,
2130 }
2131 }
2132 fn cast(syntax: SyntaxToken) -> Option<Self> {
2133 if Self::can_cast(syntax.kind()) {
2134 Some(Self { syntax })
2135 } else {
2136 None
2137 }
2138 }
2139 fn syntax(&self) -> &SyntaxToken {
2140 &self.syntax
2141 }
2142}
2143#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2144pub struct ReturnKw {
2145 pub(crate) syntax: SyntaxToken,
2146}
2147impl std::fmt::Display for ReturnKw {
2148 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2149 std::fmt::Display::fmt(&self.syntax, f)
2150 }
2151}
2152impl AstToken for ReturnKw {
2153 fn can_cast(kind: SyntaxKind) -> bool {
2154 match kind {
2155 RETURN_KW => true,
2156 _ => false,
2157 }
2158 }
2159 fn cast(syntax: SyntaxToken) -> Option<Self> {
2160 if Self::can_cast(syntax.kind()) {
2161 Some(Self { syntax })
2162 } else {
2163 None
2164 }
2165 }
2166 fn syntax(&self) -> &SyntaxToken {
2167 &self.syntax
2168 }
2169}
2170#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2171pub struct SelfKw {
2172 pub(crate) syntax: SyntaxToken,
2173}
2174impl std::fmt::Display for SelfKw {
2175 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2176 std::fmt::Display::fmt(&self.syntax, f)
2177 }
2178}
2179impl AstToken for SelfKw {
2180 fn can_cast(kind: SyntaxKind) -> bool {
2181 match kind {
2182 SELF_KW => true,
2183 _ => false,
2184 }
2185 }
2186 fn cast(syntax: SyntaxToken) -> Option<Self> {
2187 if Self::can_cast(syntax.kind()) {
2188 Some(Self { syntax })
2189 } else {
2190 None
2191 }
2192 }
2193 fn syntax(&self) -> &SyntaxToken {
2194 &self.syntax
2195 }
2196}
2197#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2198pub struct StaticKw {
2199 pub(crate) syntax: SyntaxToken,
2200}
2201impl std::fmt::Display for StaticKw {
2202 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2203 std::fmt::Display::fmt(&self.syntax, f)
2204 }
2205}
2206impl AstToken for StaticKw {
2207 fn can_cast(kind: SyntaxKind) -> bool {
2208 match kind {
2209 STATIC_KW => true,
2210 _ => false,
2211 }
2212 }
2213 fn cast(syntax: SyntaxToken) -> Option<Self> {
2214 if Self::can_cast(syntax.kind()) {
2215 Some(Self { syntax })
2216 } else {
2217 None
2218 }
2219 }
2220 fn syntax(&self) -> &SyntaxToken {
2221 &self.syntax
2222 }
2223}
2224#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2225pub struct StructKw {
2226 pub(crate) syntax: SyntaxToken,
2227}
2228impl std::fmt::Display for StructKw {
2229 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2230 std::fmt::Display::fmt(&self.syntax, f)
2231 }
2232}
2233impl AstToken for StructKw {
2234 fn can_cast(kind: SyntaxKind) -> bool {
2235 match kind {
2236 STRUCT_KW => true,
2237 _ => false,
2238 }
2239 }
2240 fn cast(syntax: SyntaxToken) -> Option<Self> {
2241 if Self::can_cast(syntax.kind()) {
2242 Some(Self { syntax })
2243 } else {
2244 None
2245 }
2246 }
2247 fn syntax(&self) -> &SyntaxToken {
2248 &self.syntax
2249 }
2250}
2251#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2252pub struct SuperKw {
2253 pub(crate) syntax: SyntaxToken,
2254}
2255impl std::fmt::Display for SuperKw {
2256 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2257 std::fmt::Display::fmt(&self.syntax, f)
2258 }
2259}
2260impl AstToken for SuperKw {
2261 fn can_cast(kind: SyntaxKind) -> bool {
2262 match kind {
2263 SUPER_KW => true,
2264 _ => false,
2265 }
2266 }
2267 fn cast(syntax: SyntaxToken) -> Option<Self> {
2268 if Self::can_cast(syntax.kind()) {
2269 Some(Self { syntax })
2270 } else {
2271 None
2272 }
2273 }
2274 fn syntax(&self) -> &SyntaxToken {
2275 &self.syntax
2276 }
2277}
2278#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2279pub struct TraitKw {
2280 pub(crate) syntax: SyntaxToken,
2281}
2282impl std::fmt::Display for TraitKw {
2283 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2284 std::fmt::Display::fmt(&self.syntax, f)
2285 }
2286}
2287impl AstToken for TraitKw {
2288 fn can_cast(kind: SyntaxKind) -> bool {
2289 match kind {
2290 TRAIT_KW => true,
2291 _ => false,
2292 }
2293 }
2294 fn cast(syntax: SyntaxToken) -> Option<Self> {
2295 if Self::can_cast(syntax.kind()) {
2296 Some(Self { syntax })
2297 } else {
2298 None
2299 }
2300 }
2301 fn syntax(&self) -> &SyntaxToken {
2302 &self.syntax
2303 }
2304}
2305#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2306pub struct TrueKw {
2307 pub(crate) syntax: SyntaxToken,
2308}
2309impl std::fmt::Display for TrueKw {
2310 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2311 std::fmt::Display::fmt(&self.syntax, f)
2312 }
2313}
2314impl AstToken for TrueKw {
2315 fn can_cast(kind: SyntaxKind) -> bool {
2316 match kind {
2317 TRUE_KW => true,
2318 _ => false,
2319 }
2320 }
2321 fn cast(syntax: SyntaxToken) -> Option<Self> {
2322 if Self::can_cast(syntax.kind()) {
2323 Some(Self { syntax })
2324 } else {
2325 None
2326 }
2327 }
2328 fn syntax(&self) -> &SyntaxToken {
2329 &self.syntax
2330 }
2331}
2332#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2333pub struct TryKw {
2334 pub(crate) syntax: SyntaxToken,
2335}
2336impl std::fmt::Display for TryKw {
2337 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2338 std::fmt::Display::fmt(&self.syntax, f)
2339 }
2340}
2341impl AstToken for TryKw {
2342 fn can_cast(kind: SyntaxKind) -> bool {
2343 match kind {
2344 TRY_KW => true,
2345 _ => false,
2346 }
2347 }
2348 fn cast(syntax: SyntaxToken) -> Option<Self> {
2349 if Self::can_cast(syntax.kind()) {
2350 Some(Self { syntax })
2351 } else {
2352 None
2353 }
2354 }
2355 fn syntax(&self) -> &SyntaxToken {
2356 &self.syntax
2357 }
2358}
2359#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2360pub struct TypeKw {
2361 pub(crate) syntax: SyntaxToken,
2362}
2363impl std::fmt::Display for TypeKw {
2364 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2365 std::fmt::Display::fmt(&self.syntax, f)
2366 }
2367}
2368impl AstToken for TypeKw {
2369 fn can_cast(kind: SyntaxKind) -> bool {
2370 match kind {
2371 TYPE_KW => true,
2372 _ => false,
2373 }
2374 }
2375 fn cast(syntax: SyntaxToken) -> Option<Self> {
2376 if Self::can_cast(syntax.kind()) {
2377 Some(Self { syntax })
2378 } else {
2379 None
2380 }
2381 }
2382 fn syntax(&self) -> &SyntaxToken {
2383 &self.syntax
2384 }
2385}
2386#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2387pub struct UnsafeKw {
2388 pub(crate) syntax: SyntaxToken,
2389}
2390impl std::fmt::Display for UnsafeKw {
2391 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2392 std::fmt::Display::fmt(&self.syntax, f)
2393 }
2394}
2395impl AstToken for UnsafeKw {
2396 fn can_cast(kind: SyntaxKind) -> bool {
2397 match kind {
2398 UNSAFE_KW => true,
2399 _ => false,
2400 }
2401 }
2402 fn cast(syntax: SyntaxToken) -> Option<Self> {
2403 if Self::can_cast(syntax.kind()) {
2404 Some(Self { syntax })
2405 } else {
2406 None
2407 }
2408 }
2409 fn syntax(&self) -> &SyntaxToken {
2410 &self.syntax
2411 }
2412}
2413#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2414pub struct UseKw {
2415 pub(crate) syntax: SyntaxToken,
2416}
2417impl std::fmt::Display for UseKw {
2418 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2419 std::fmt::Display::fmt(&self.syntax, f)
2420 }
2421}
2422impl AstToken for UseKw {
2423 fn can_cast(kind: SyntaxKind) -> bool {
2424 match kind {
2425 USE_KW => true,
2426 _ => false,
2427 }
2428 }
2429 fn cast(syntax: SyntaxToken) -> Option<Self> {
2430 if Self::can_cast(syntax.kind()) {
2431 Some(Self { syntax })
2432 } else {
2433 None
2434 }
2435 }
2436 fn syntax(&self) -> &SyntaxToken {
2437 &self.syntax
2438 }
2439}
2440#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2441pub struct WhereKw {
2442 pub(crate) syntax: SyntaxToken,
2443}
2444impl std::fmt::Display for WhereKw {
2445 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2446 std::fmt::Display::fmt(&self.syntax, f)
2447 }
2448}
2449impl AstToken for WhereKw {
2450 fn can_cast(kind: SyntaxKind) -> bool {
2451 match kind {
2452 WHERE_KW => true,
2453 _ => false,
2454 }
2455 }
2456 fn cast(syntax: SyntaxToken) -> Option<Self> {
2457 if Self::can_cast(syntax.kind()) {
2458 Some(Self { syntax })
2459 } else {
2460 None
2461 }
2462 }
2463 fn syntax(&self) -> &SyntaxToken {
2464 &self.syntax
2465 }
2466}
2467#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2468pub struct WhileKw {
2469 pub(crate) syntax: SyntaxToken,
2470}
2471impl std::fmt::Display for WhileKw {
2472 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2473 std::fmt::Display::fmt(&self.syntax, f)
2474 }
2475}
2476impl AstToken for WhileKw {
2477 fn can_cast(kind: SyntaxKind) -> bool {
2478 match kind {
2479 WHILE_KW => true,
2480 _ => false,
2481 }
2482 }
2483 fn cast(syntax: SyntaxToken) -> Option<Self> {
2484 if Self::can_cast(syntax.kind()) {
2485 Some(Self { syntax })
2486 } else {
2487 None
2488 }
2489 }
2490 fn syntax(&self) -> &SyntaxToken {
2491 &self.syntax
2492 }
2493}
2494#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2495pub struct AutoKw {
2496 pub(crate) syntax: SyntaxToken,
2497}
2498impl std::fmt::Display for AutoKw {
2499 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2500 std::fmt::Display::fmt(&self.syntax, f)
2501 }
2502}
2503impl AstToken for AutoKw {
2504 fn can_cast(kind: SyntaxKind) -> bool {
2505 match kind {
2506 AUTO_KW => true,
2507 _ => false,
2508 }
2509 }
2510 fn cast(syntax: SyntaxToken) -> Option<Self> {
2511 if Self::can_cast(syntax.kind()) {
2512 Some(Self { syntax })
2513 } else {
2514 None
2515 }
2516 }
2517 fn syntax(&self) -> &SyntaxToken {
2518 &self.syntax
2519 }
2520}
2521#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2522pub struct DefaultKw {
2523 pub(crate) syntax: SyntaxToken,
2524}
2525impl std::fmt::Display for DefaultKw {
2526 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2527 std::fmt::Display::fmt(&self.syntax, f)
2528 }
2529}
2530impl AstToken for DefaultKw {
2531 fn can_cast(kind: SyntaxKind) -> bool {
2532 match kind {
2533 DEFAULT_KW => true,
2534 _ => false,
2535 }
2536 }
2537 fn cast(syntax: SyntaxToken) -> Option<Self> {
2538 if Self::can_cast(syntax.kind()) {
2539 Some(Self { syntax })
2540 } else {
2541 None
2542 }
2543 }
2544 fn syntax(&self) -> &SyntaxToken {
2545 &self.syntax
2546 }
2547}
2548#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2549pub struct ExistentialKw {
2550 pub(crate) syntax: SyntaxToken,
2551}
2552impl std::fmt::Display for ExistentialKw {
2553 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2554 std::fmt::Display::fmt(&self.syntax, f)
2555 }
2556}
2557impl AstToken for ExistentialKw {
2558 fn can_cast(kind: SyntaxKind) -> bool {
2559 match kind {
2560 EXISTENTIAL_KW => true,
2561 _ => false,
2562 }
2563 }
2564 fn cast(syntax: SyntaxToken) -> Option<Self> {
2565 if Self::can_cast(syntax.kind()) {
2566 Some(Self { syntax })
2567 } else {
2568 None
2569 }
2570 }
2571 fn syntax(&self) -> &SyntaxToken {
2572 &self.syntax
2573 }
2574}
2575#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2576pub struct UnionKw {
2577 pub(crate) syntax: SyntaxToken,
2578}
2579impl std::fmt::Display for UnionKw {
2580 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2581 std::fmt::Display::fmt(&self.syntax, f)
2582 }
2583}
2584impl AstToken for UnionKw {
2585 fn can_cast(kind: SyntaxKind) -> bool {
2586 match kind {
2587 UNION_KW => true,
2588 _ => false,
2589 }
2590 }
2591 fn cast(syntax: SyntaxToken) -> Option<Self> {
2592 if Self::can_cast(syntax.kind()) {
2593 Some(Self { syntax })
2594 } else {
2595 None
2596 }
2597 }
2598 fn syntax(&self) -> &SyntaxToken {
2599 &self.syntax
2600 }
2601}
2602#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2603pub struct RawKw {
2604 pub(crate) syntax: SyntaxToken,
2605}
2606impl std::fmt::Display for RawKw {
2607 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2608 std::fmt::Display::fmt(&self.syntax, f)
2609 }
2610}
2611impl AstToken for RawKw {
2612 fn can_cast(kind: SyntaxKind) -> bool {
2613 match kind {
2614 RAW_KW => true,
2615 _ => false,
2616 }
2617 }
2618 fn cast(syntax: SyntaxToken) -> Option<Self> {
2619 if Self::can_cast(syntax.kind()) {
2620 Some(Self { syntax })
2621 } else {
2622 None
2623 }
2624 }
2625 fn syntax(&self) -> &SyntaxToken {
2626 &self.syntax
2627 }
2628}
2629#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2630pub struct IntNumber {
2631 pub(crate) syntax: SyntaxToken,
2632}
2633impl std::fmt::Display for IntNumber {
2634 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2635 std::fmt::Display::fmt(&self.syntax, f)
2636 }
2637}
2638impl AstToken for IntNumber {
2639 fn can_cast(kind: SyntaxKind) -> bool {
2640 match kind {
2641 INT_NUMBER => true,
2642 _ => false,
2643 }
2644 }
2645 fn cast(syntax: SyntaxToken) -> Option<Self> {
2646 if Self::can_cast(syntax.kind()) {
2647 Some(Self { syntax })
2648 } else {
2649 None
2650 }
2651 }
2652 fn syntax(&self) -> &SyntaxToken {
2653 &self.syntax
2654 }
2655}
2656#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2657pub struct FloatNumber {
2658 pub(crate) syntax: SyntaxToken,
2659}
2660impl std::fmt::Display for FloatNumber {
2661 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2662 std::fmt::Display::fmt(&self.syntax, f)
2663 }
2664}
2665impl AstToken for FloatNumber {
2666 fn can_cast(kind: SyntaxKind) -> bool {
2667 match kind {
2668 FLOAT_NUMBER => true,
2669 _ => false,
2670 }
2671 }
2672 fn cast(syntax: SyntaxToken) -> Option<Self> {
2673 if Self::can_cast(syntax.kind()) {
2674 Some(Self { syntax })
2675 } else {
2676 None
2677 }
2678 }
2679 fn syntax(&self) -> &SyntaxToken {
2680 &self.syntax
2681 }
2682}
2683#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2684pub struct Char {
2685 pub(crate) syntax: SyntaxToken,
2686}
2687impl std::fmt::Display for Char {
2688 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2689 std::fmt::Display::fmt(&self.syntax, f)
2690 }
2691}
2692impl AstToken for Char {
2693 fn can_cast(kind: SyntaxKind) -> bool {
2694 match kind {
2695 CHAR => true,
2696 _ => false,
2697 }
2698 }
2699 fn cast(syntax: SyntaxToken) -> Option<Self> {
2700 if Self::can_cast(syntax.kind()) {
2701 Some(Self { syntax })
2702 } else {
2703 None
2704 }
2705 }
2706 fn syntax(&self) -> &SyntaxToken {
2707 &self.syntax
2708 }
2709}
2710#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2711pub struct Byte {
2712 pub(crate) syntax: SyntaxToken,
2713}
2714impl std::fmt::Display for Byte {
2715 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2716 std::fmt::Display::fmt(&self.syntax, f)
2717 }
2718}
2719impl AstToken for Byte {
2720 fn can_cast(kind: SyntaxKind) -> bool {
2721 match kind {
2722 BYTE => true,
2723 _ => false,
2724 }
2725 }
2726 fn cast(syntax: SyntaxToken) -> Option<Self> {
2727 if Self::can_cast(syntax.kind()) {
2728 Some(Self { syntax })
2729 } else {
2730 None
2731 }
2732 }
2733 fn syntax(&self) -> &SyntaxToken {
2734 &self.syntax
2735 }
2736}
2737#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2738pub struct String {
2739 pub(crate) syntax: SyntaxToken,
2740}
2741impl std::fmt::Display for String {
2742 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2743 std::fmt::Display::fmt(&self.syntax, f)
2744 }
2745}
2746impl AstToken for String {
2747 fn can_cast(kind: SyntaxKind) -> bool {
2748 match kind {
2749 STRING => true,
2750 _ => false,
2751 }
2752 }
2753 fn cast(syntax: SyntaxToken) -> Option<Self> {
2754 if Self::can_cast(syntax.kind()) {
2755 Some(Self { syntax })
2756 } else {
2757 None
2758 }
2759 }
2760 fn syntax(&self) -> &SyntaxToken {
2761 &self.syntax
2762 }
2763}
2764#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2765pub struct RawString {
2766 pub(crate) syntax: SyntaxToken,
2767}
2768impl std::fmt::Display for RawString {
2769 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2770 std::fmt::Display::fmt(&self.syntax, f)
2771 }
2772}
2773impl AstToken for RawString {
2774 fn can_cast(kind: SyntaxKind) -> bool {
2775 match kind {
2776 RAW_STRING => true,
2777 _ => false,
2778 }
2779 }
2780 fn cast(syntax: SyntaxToken) -> Option<Self> {
2781 if Self::can_cast(syntax.kind()) {
2782 Some(Self { syntax })
2783 } else {
2784 None
2785 }
2786 }
2787 fn syntax(&self) -> &SyntaxToken {
2788 &self.syntax
2789 }
2790}
2791#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2792pub struct ByteString {
2793 pub(crate) syntax: SyntaxToken,
2794}
2795impl std::fmt::Display for ByteString {
2796 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2797 std::fmt::Display::fmt(&self.syntax, f)
2798 }
2799}
2800impl AstToken for ByteString {
2801 fn can_cast(kind: SyntaxKind) -> bool {
2802 match kind {
2803 BYTE_STRING => true,
2804 _ => false,
2805 }
2806 }
2807 fn cast(syntax: SyntaxToken) -> Option<Self> {
2808 if Self::can_cast(syntax.kind()) {
2809 Some(Self { syntax })
2810 } else {
2811 None
2812 }
2813 }
2814 fn syntax(&self) -> &SyntaxToken {
2815 &self.syntax
2816 }
2817}
2818#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2819pub struct RawByteString {
2820 pub(crate) syntax: SyntaxToken,
2821}
2822impl std::fmt::Display for RawByteString {
2823 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2824 std::fmt::Display::fmt(&self.syntax, f)
2825 }
2826}
2827impl AstToken for RawByteString {
2828 fn can_cast(kind: SyntaxKind) -> bool {
2829 match kind {
2830 RAW_BYTE_STRING => true,
2831 _ => false,
2832 }
2833 }
2834 fn cast(syntax: SyntaxToken) -> Option<Self> {
2835 if Self::can_cast(syntax.kind()) {
2836 Some(Self { syntax })
2837 } else {
2838 None
2839 }
2840 }
2841 fn syntax(&self) -> &SyntaxToken {
2842 &self.syntax
2843 }
2844}
2845#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2846pub struct Error {
2847 pub(crate) syntax: SyntaxToken,
2848}
2849impl std::fmt::Display for Error {
2850 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2851 std::fmt::Display::fmt(&self.syntax, f)
2852 }
2853}
2854impl AstToken for Error {
2855 fn can_cast(kind: SyntaxKind) -> bool {
2856 match kind {
2857 ERROR => true,
2858 _ => false,
2859 }
2860 }
2861 fn cast(syntax: SyntaxToken) -> Option<Self> {
2862 if Self::can_cast(syntax.kind()) {
2863 Some(Self { syntax })
2864 } else {
2865 None
2866 }
2867 }
2868 fn syntax(&self) -> &SyntaxToken {
2869 &self.syntax
2870 }
2871}
2872#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2873pub struct Ident {
2874 pub(crate) syntax: SyntaxToken,
2875}
2876impl std::fmt::Display for Ident {
2877 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2878 std::fmt::Display::fmt(&self.syntax, f)
2879 }
2880}
2881impl AstToken for Ident {
2882 fn can_cast(kind: SyntaxKind) -> bool {
2883 match kind {
2884 IDENT => true,
2885 _ => false,
2886 }
2887 }
2888 fn cast(syntax: SyntaxToken) -> Option<Self> {
2889 if Self::can_cast(syntax.kind()) {
2890 Some(Self { syntax })
2891 } else {
2892 None
2893 }
2894 }
2895 fn syntax(&self) -> &SyntaxToken {
2896 &self.syntax
2897 }
2898}
2899#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2900pub struct Whitespace {
2901 pub(crate) syntax: SyntaxToken,
2902}
2903impl std::fmt::Display for Whitespace {
2904 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2905 std::fmt::Display::fmt(&self.syntax, f)
2906 }
2907}
2908impl AstToken for Whitespace {
2909 fn can_cast(kind: SyntaxKind) -> bool {
2910 match kind {
2911 WHITESPACE => true,
2912 _ => false,
2913 }
2914 }
2915 fn cast(syntax: SyntaxToken) -> Option<Self> {
2916 if Self::can_cast(syntax.kind()) {
2917 Some(Self { syntax })
2918 } else {
2919 None
2920 }
2921 }
2922 fn syntax(&self) -> &SyntaxToken {
2923 &self.syntax
2924 }
2925}
2926#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2927pub struct Lifetime {
2928 pub(crate) syntax: SyntaxToken,
2929}
2930impl std::fmt::Display for Lifetime {
2931 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2932 std::fmt::Display::fmt(&self.syntax, f)
2933 }
2934}
2935impl AstToken for Lifetime {
2936 fn can_cast(kind: SyntaxKind) -> bool {
2937 match kind {
2938 LIFETIME => true,
2939 _ => false,
2940 }
2941 }
2942 fn cast(syntax: SyntaxToken) -> Option<Self> {
2943 if Self::can_cast(syntax.kind()) {
2944 Some(Self { syntax })
2945 } else {
2946 None
2947 }
2948 }
2949 fn syntax(&self) -> &SyntaxToken {
2950 &self.syntax
2951 }
2952}
2953#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2954pub struct Comment {
2955 pub(crate) syntax: SyntaxToken,
2956}
2957impl std::fmt::Display for Comment {
2958 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2959 std::fmt::Display::fmt(&self.syntax, f)
2960 }
2961}
2962impl AstToken for Comment {
2963 fn can_cast(kind: SyntaxKind) -> bool {
2964 match kind {
2965 COMMENT => true,
2966 _ => false,
2967 }
2968 }
2969 fn cast(syntax: SyntaxToken) -> Option<Self> {
2970 if Self::can_cast(syntax.kind()) {
2971 Some(Self { syntax })
2972 } else {
2973 None
2974 }
2975 }
2976 fn syntax(&self) -> &SyntaxToken {
2977 &self.syntax
2978 }
2979}
2980#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2981pub struct Shebang {
2982 pub(crate) syntax: SyntaxToken,
2983}
2984impl std::fmt::Display for Shebang {
2985 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2986 std::fmt::Display::fmt(&self.syntax, f)
2987 }
2988}
2989impl AstToken for Shebang {
2990 fn can_cast(kind: SyntaxKind) -> bool {
2991 match kind {
2992 SHEBANG => true,
2993 _ => false,
2994 }
2995 }
2996 fn cast(syntax: SyntaxToken) -> Option<Self> {
2997 if Self::can_cast(syntax.kind()) {
2998 Some(Self { syntax })
2999 } else {
3000 None
3001 }
3002 }
3003 fn syntax(&self) -> &SyntaxToken {
3004 &self.syntax
3005 }
3006}
3007#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3008pub struct LDollar {
3009 pub(crate) syntax: SyntaxToken,
3010}
3011impl std::fmt::Display for LDollar {
3012 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3013 std::fmt::Display::fmt(&self.syntax, f)
3014 }
3015}
3016impl AstToken for LDollar {
3017 fn can_cast(kind: SyntaxKind) -> bool {
3018 match kind {
3019 L_DOLLAR => true,
3020 _ => false,
3021 }
3022 }
3023 fn cast(syntax: SyntaxToken) -> Option<Self> {
3024 if Self::can_cast(syntax.kind()) {
3025 Some(Self { syntax })
3026 } else {
3027 None
3028 }
3029 }
3030 fn syntax(&self) -> &SyntaxToken {
3031 &self.syntax
3032 }
3033}
3034#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3035pub struct RDollar {
3036 pub(crate) syntax: SyntaxToken,
3037}
3038impl std::fmt::Display for RDollar {
3039 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3040 std::fmt::Display::fmt(&self.syntax, f)
3041 }
3042}
3043impl AstToken for RDollar {
3044 fn can_cast(kind: SyntaxKind) -> bool {
3045 match kind {
3046 R_DOLLAR => true,
3047 _ => false,
3048 }
3049 }
3050 fn cast(syntax: SyntaxToken) -> Option<Self> {
3051 if Self::can_cast(syntax.kind()) {
3052 Some(Self { syntax })
3053 } else {
3054 None
3055 }
3056 }
3057 fn syntax(&self) -> &SyntaxToken {
3058 &self.syntax
3059 }
3060}
3061#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3062pub struct SourceFile {
3063 pub(crate) syntax: SyntaxNode,
3064}
3065impl std::fmt::Display for SourceFile {
3066 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3067 std::fmt::Display::fmt(self.syntax(), f)
3068 }
3069}
3070impl AstNode for SourceFile {
3071 fn can_cast(kind: SyntaxKind) -> bool {
3072 match kind {
3073 SOURCE_FILE => true,
3074 _ => false,
3075 }
3076 }
3077 fn cast(syntax: SyntaxNode) -> Option<Self> {
3078 if Self::can_cast(syntax.kind()) {
3079 Some(Self { syntax })
3080 } else {
3081 None
3082 }
3083 }
3084 fn syntax(&self) -> &SyntaxNode {
3085 &self.syntax
3086 }
3087}
3088impl ast::ModuleItemOwner for SourceFile {}
3089impl ast::FnDefOwner for SourceFile {}
3090impl ast::AttrsOwner for SourceFile {}
3091impl SourceFile {
3092 pub fn modules(&self) -> AstChildren<Module> {
3093 support::children(&self.syntax)
3094 }
3095}
3096#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3097pub struct FnDef {
3098 pub(crate) syntax: SyntaxNode,
3099}
3100impl std::fmt::Display for FnDef {
3101 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3102 std::fmt::Display::fmt(self.syntax(), f)
3103 }
3104}
3105impl AstNode for FnDef {
3106 fn can_cast(kind: SyntaxKind) -> bool {
3107 match kind {
3108 FN_DEF => true,
3109 _ => false,
3110 }
3111 }
3112 fn cast(syntax: SyntaxNode) -> Option<Self> {
3113 if Self::can_cast(syntax.kind()) {
3114 Some(Self { syntax })
3115 } else {
3116 None
3117 }
3118 }
3119 fn syntax(&self) -> &SyntaxNode {
3120 &self.syntax
3121 }
3122}
3123impl ast::VisibilityOwner for FnDef {}
3124impl ast::NameOwner for FnDef {}
3125impl ast::TypeParamsOwner for FnDef {}
3126impl ast::DocCommentsOwner for FnDef {}
3127impl ast::AttrsOwner for FnDef {}
3128impl FnDef {
3129 pub fn abi(&self) -> Option<Abi> {
3130 support::child(&self.syntax)
3131 }
3132 pub fn const_kw(&self) -> Option<ConstKw> {
3133 support::token(&self.syntax)
3134 }
3135 pub fn default_kw(&self) -> Option<DefaultKw> {
3136 support::token(&self.syntax)
3137 }
3138 pub fn async_kw(&self) -> Option<AsyncKw> {
3139 support::token(&self.syntax)
3140 }
3141 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
3142 support::token(&self.syntax)
3143 }
3144 pub fn fn_kw(&self) -> Option<FnKw> {
3145 support::token(&self.syntax)
3146 }
3147 pub fn param_list(&self) -> Option<ParamList> {
3148 support::child(&self.syntax)
3149 }
3150 pub fn ret_type(&self) -> Option<RetType> {
3151 support::child(&self.syntax)
3152 }
3153 pub fn body(&self) -> Option<BlockExpr> {
3154 support::child(&self.syntax)
3155 }
3156 pub fn semi(&self) -> Option<Semi> {
3157 support::token(&self.syntax)
3158 }
3159}
3160#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3161pub struct RetType {
3162 pub(crate) syntax: SyntaxNode,
3163}
3164impl std::fmt::Display for RetType {
3165 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3166 std::fmt::Display::fmt(self.syntax(), f)
3167 }
3168}
3169impl AstNode for RetType {
3170 fn can_cast(kind: SyntaxKind) -> bool {
3171 match kind {
3172 RET_TYPE => true,
3173 _ => false,
3174 }
3175 }
3176 fn cast(syntax: SyntaxNode) -> Option<Self> {
3177 if Self::can_cast(syntax.kind()) {
3178 Some(Self { syntax })
3179 } else {
3180 None
3181 }
3182 }
3183 fn syntax(&self) -> &SyntaxNode {
3184 &self.syntax
3185 }
3186}
3187impl RetType {
3188 pub fn thin_arrow(&self) -> Option<ThinArrow> {
3189 support::token(&self.syntax)
3190 }
3191 pub fn type_ref(&self) -> Option<TypeRef> {
3192 support::child(&self.syntax)
3193 }
3194}
3195#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3196pub struct StructDef {
3197 pub(crate) syntax: SyntaxNode,
3198}
3199impl std::fmt::Display for StructDef {
3200 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3201 std::fmt::Display::fmt(self.syntax(), f)
3202 }
3203}
3204impl AstNode for StructDef {
3205 fn can_cast(kind: SyntaxKind) -> bool {
3206 match kind {
3207 STRUCT_DEF => true,
3208 _ => false,
3209 }
3210 }
3211 fn cast(syntax: SyntaxNode) -> Option<Self> {
3212 if Self::can_cast(syntax.kind()) {
3213 Some(Self { syntax })
3214 } else {
3215 None
3216 }
3217 }
3218 fn syntax(&self) -> &SyntaxNode {
3219 &self.syntax
3220 }
3221}
3222impl ast::VisibilityOwner for StructDef {}
3223impl ast::NameOwner for StructDef {}
3224impl ast::TypeParamsOwner for StructDef {}
3225impl ast::AttrsOwner for StructDef {}
3226impl ast::DocCommentsOwner for StructDef {}
3227impl StructDef {
3228 pub fn struct_kw(&self) -> Option<StructKw> {
3229 support::token(&self.syntax)
3230 }
3231 pub fn field_def_list(&self) -> Option<FieldDefList> {
3232 support::child(&self.syntax)
3233 }
3234 pub fn semi(&self) -> Option<Semi> {
3235 support::token(&self.syntax)
3236 }
3237}
3238#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3239pub struct UnionDef {
3240 pub(crate) syntax: SyntaxNode,
3241}
3242impl std::fmt::Display for UnionDef {
3243 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3244 std::fmt::Display::fmt(self.syntax(), f)
3245 }
3246}
3247impl AstNode for UnionDef {
3248 fn can_cast(kind: SyntaxKind) -> bool {
3249 match kind {
3250 UNION_DEF => true,
3251 _ => false,
3252 }
3253 }
3254 fn cast(syntax: SyntaxNode) -> Option<Self> {
3255 if Self::can_cast(syntax.kind()) {
3256 Some(Self { syntax })
3257 } else {
3258 None
3259 }
3260 }
3261 fn syntax(&self) -> &SyntaxNode {
3262 &self.syntax
3263 }
3264}
3265impl ast::VisibilityOwner for UnionDef {}
3266impl ast::NameOwner for UnionDef {}
3267impl ast::TypeParamsOwner for UnionDef {}
3268impl ast::AttrsOwner for UnionDef {}
3269impl ast::DocCommentsOwner for UnionDef {}
3270impl UnionDef {
3271 pub fn union_kw(&self) -> Option<UnionKw> {
3272 support::token(&self.syntax)
3273 }
3274 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
3275 support::child(&self.syntax)
3276 }
3277}
3278#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3279pub struct RecordFieldDefList {
3280 pub(crate) syntax: SyntaxNode,
3281}
3282impl std::fmt::Display for RecordFieldDefList {
3283 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3284 std::fmt::Display::fmt(self.syntax(), f)
3285 }
3286}
3287impl AstNode for RecordFieldDefList {
3288 fn can_cast(kind: SyntaxKind) -> bool {
3289 match kind {
3290 RECORD_FIELD_DEF_LIST => true,
3291 _ => false,
3292 }
3293 }
3294 fn cast(syntax: SyntaxNode) -> Option<Self> {
3295 if Self::can_cast(syntax.kind()) {
3296 Some(Self { syntax })
3297 } else {
3298 None
3299 }
3300 }
3301 fn syntax(&self) -> &SyntaxNode {
3302 &self.syntax
3303 }
3304}
3305impl RecordFieldDefList {
3306 pub fn l_curly(&self) -> Option<LCurly> {
3307 support::token(&self.syntax)
3308 }
3309 pub fn fields(&self) -> AstChildren<RecordFieldDef> {
3310 support::children(&self.syntax)
3311 }
3312 pub fn r_curly(&self) -> Option<RCurly> {
3313 support::token(&self.syntax)
3314 }
3315}
3316#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3317pub struct RecordFieldDef {
3318 pub(crate) syntax: SyntaxNode,
3319}
3320impl std::fmt::Display for RecordFieldDef {
3321 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3322 std::fmt::Display::fmt(self.syntax(), f)
3323 }
3324}
3325impl AstNode for RecordFieldDef {
3326 fn can_cast(kind: SyntaxKind) -> bool {
3327 match kind {
3328 RECORD_FIELD_DEF => true,
3329 _ => false,
3330 }
3331 }
3332 fn cast(syntax: SyntaxNode) -> Option<Self> {
3333 if Self::can_cast(syntax.kind()) {
3334 Some(Self { syntax })
3335 } else {
3336 None
3337 }
3338 }
3339 fn syntax(&self) -> &SyntaxNode {
3340 &self.syntax
3341 }
3342}
3343impl ast::VisibilityOwner for RecordFieldDef {}
3344impl ast::NameOwner for RecordFieldDef {}
3345impl ast::AttrsOwner for RecordFieldDef {}
3346impl ast::DocCommentsOwner for RecordFieldDef {}
3347impl ast::TypeAscriptionOwner for RecordFieldDef {}
3348impl RecordFieldDef {}
3349#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3350pub struct TupleFieldDefList {
3351 pub(crate) syntax: SyntaxNode,
3352}
3353impl std::fmt::Display for TupleFieldDefList {
3354 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3355 std::fmt::Display::fmt(self.syntax(), f)
3356 }
3357}
3358impl AstNode for TupleFieldDefList {
3359 fn can_cast(kind: SyntaxKind) -> bool {
3360 match kind {
3361 TUPLE_FIELD_DEF_LIST => true,
3362 _ => false,
3363 }
3364 }
3365 fn cast(syntax: SyntaxNode) -> Option<Self> {
3366 if Self::can_cast(syntax.kind()) {
3367 Some(Self { syntax })
3368 } else {
3369 None
3370 }
3371 }
3372 fn syntax(&self) -> &SyntaxNode {
3373 &self.syntax
3374 }
3375}
3376impl TupleFieldDefList {
3377 pub fn l_paren(&self) -> Option<LParen> {
3378 support::token(&self.syntax)
3379 }
3380 pub fn fields(&self) -> AstChildren<TupleFieldDef> {
3381 support::children(&self.syntax)
3382 }
3383 pub fn r_paren(&self) -> Option<RParen> {
3384 support::token(&self.syntax)
3385 }
3386}
3387#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3388pub struct TupleFieldDef {
3389 pub(crate) syntax: SyntaxNode,
3390}
3391impl std::fmt::Display for TupleFieldDef {
3392 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3393 std::fmt::Display::fmt(self.syntax(), f)
3394 }
3395}
3396impl AstNode for TupleFieldDef {
3397 fn can_cast(kind: SyntaxKind) -> bool {
3398 match kind {
3399 TUPLE_FIELD_DEF => true,
3400 _ => false,
3401 }
3402 }
3403 fn cast(syntax: SyntaxNode) -> Option<Self> {
3404 if Self::can_cast(syntax.kind()) {
3405 Some(Self { syntax })
3406 } else {
3407 None
3408 }
3409 }
3410 fn syntax(&self) -> &SyntaxNode {
3411 &self.syntax
3412 }
3413}
3414impl ast::VisibilityOwner for TupleFieldDef {}
3415impl ast::AttrsOwner for TupleFieldDef {}
3416impl TupleFieldDef {
3417 pub fn type_ref(&self) -> Option<TypeRef> {
3418 support::child(&self.syntax)
3419 }
3420}
3421#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3422pub struct EnumDef {
3423 pub(crate) syntax: SyntaxNode,
3424}
3425impl std::fmt::Display for EnumDef {
3426 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3427 std::fmt::Display::fmt(self.syntax(), f)
3428 }
3429}
3430impl AstNode for EnumDef {
3431 fn can_cast(kind: SyntaxKind) -> bool {
3432 match kind {
3433 ENUM_DEF => true,
3434 _ => false,
3435 }
3436 }
3437 fn cast(syntax: SyntaxNode) -> Option<Self> {
3438 if Self::can_cast(syntax.kind()) {
3439 Some(Self { syntax })
3440 } else {
3441 None
3442 }
3443 }
3444 fn syntax(&self) -> &SyntaxNode {
3445 &self.syntax
3446 }
3447}
3448impl ast::VisibilityOwner for EnumDef {}
3449impl ast::NameOwner for EnumDef {}
3450impl ast::TypeParamsOwner for EnumDef {}
3451impl ast::AttrsOwner for EnumDef {}
3452impl ast::DocCommentsOwner for EnumDef {}
3453impl EnumDef {
3454 pub fn enum_kw(&self) -> Option<EnumKw> {
3455 support::token(&self.syntax)
3456 }
3457 pub fn variant_list(&self) -> Option<EnumVariantList> {
3458 support::child(&self.syntax)
3459 }
3460}
3461#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3462pub struct EnumVariantList {
3463 pub(crate) syntax: SyntaxNode,
3464}
3465impl std::fmt::Display for EnumVariantList {
3466 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3467 std::fmt::Display::fmt(self.syntax(), f)
3468 }
3469}
3470impl AstNode for EnumVariantList {
3471 fn can_cast(kind: SyntaxKind) -> bool {
3472 match kind {
3473 ENUM_VARIANT_LIST => true,
3474 _ => false,
3475 }
3476 }
3477 fn cast(syntax: SyntaxNode) -> Option<Self> {
3478 if Self::can_cast(syntax.kind()) {
3479 Some(Self { syntax })
3480 } else {
3481 None
3482 }
3483 }
3484 fn syntax(&self) -> &SyntaxNode {
3485 &self.syntax
3486 }
3487}
3488impl EnumVariantList {
3489 pub fn l_curly(&self) -> Option<LCurly> {
3490 support::token(&self.syntax)
3491 }
3492 pub fn variants(&self) -> AstChildren<EnumVariant> {
3493 support::children(&self.syntax)
3494 }
3495 pub fn r_curly(&self) -> Option<RCurly> {
3496 support::token(&self.syntax)
3497 }
3498}
3499#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3500pub struct EnumVariant {
3501 pub(crate) syntax: SyntaxNode,
3502}
3503impl std::fmt::Display for EnumVariant {
3504 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3505 std::fmt::Display::fmt(self.syntax(), f)
3506 }
3507}
3508impl AstNode for EnumVariant {
3509 fn can_cast(kind: SyntaxKind) -> bool {
3510 match kind {
3511 ENUM_VARIANT => true,
3512 _ => false,
3513 }
3514 }
3515 fn cast(syntax: SyntaxNode) -> Option<Self> {
3516 if Self::can_cast(syntax.kind()) {
3517 Some(Self { syntax })
3518 } else {
3519 None
3520 }
3521 }
3522 fn syntax(&self) -> &SyntaxNode {
3523 &self.syntax
3524 }
3525}
3526impl ast::VisibilityOwner for EnumVariant {}
3527impl ast::NameOwner for EnumVariant {}
3528impl ast::DocCommentsOwner for EnumVariant {}
3529impl ast::AttrsOwner for EnumVariant {}
3530impl EnumVariant {
3531 pub fn field_def_list(&self) -> Option<FieldDefList> {
3532 support::child(&self.syntax)
3533 }
3534 pub fn eq(&self) -> Option<Eq> {
3535 support::token(&self.syntax)
3536 }
3537 pub fn expr(&self) -> Option<Expr> {
3538 support::child(&self.syntax)
3539 }
3540}
3541#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3542pub struct TraitDef {
3543 pub(crate) syntax: SyntaxNode,
3544}
3545impl std::fmt::Display for TraitDef {
3546 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3547 std::fmt::Display::fmt(self.syntax(), f)
3548 }
3549}
3550impl AstNode for TraitDef {
3551 fn can_cast(kind: SyntaxKind) -> bool {
3552 match kind {
3553 TRAIT_DEF => true,
3554 _ => false,
3555 }
3556 }
3557 fn cast(syntax: SyntaxNode) -> Option<Self> {
3558 if Self::can_cast(syntax.kind()) {
3559 Some(Self { syntax })
3560 } else {
3561 None
3562 }
3563 }
3564 fn syntax(&self) -> &SyntaxNode {
3565 &self.syntax
3566 }
3567}
3568impl ast::VisibilityOwner for TraitDef {}
3569impl ast::NameOwner for TraitDef {}
3570impl ast::AttrsOwner for TraitDef {}
3571impl ast::DocCommentsOwner for TraitDef {}
3572impl ast::TypeParamsOwner for TraitDef {}
3573impl ast::TypeBoundsOwner for TraitDef {}
3574impl TraitDef {
3575 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
3576 support::token(&self.syntax)
3577 }
3578 pub fn auto_kw(&self) -> Option<AutoKw> {
3579 support::token(&self.syntax)
3580 }
3581 pub fn trait_kw(&self) -> Option<TraitKw> {
3582 support::token(&self.syntax)
3583 }
3584 pub fn item_list(&self) -> Option<ItemList> {
3585 support::child(&self.syntax)
3586 }
3587}
3588#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3589pub struct Module {
3590 pub(crate) syntax: SyntaxNode,
3591}
3592impl std::fmt::Display for Module {
3593 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3594 std::fmt::Display::fmt(self.syntax(), f)
3595 }
3596}
3597impl AstNode for Module {
3598 fn can_cast(kind: SyntaxKind) -> bool {
3599 match kind {
3600 MODULE => true,
3601 _ => false,
3602 }
3603 }
3604 fn cast(syntax: SyntaxNode) -> Option<Self> {
3605 if Self::can_cast(syntax.kind()) {
3606 Some(Self { syntax })
3607 } else {
3608 None
3609 }
3610 }
3611 fn syntax(&self) -> &SyntaxNode {
3612 &self.syntax
3613 }
3614}
3615impl ast::VisibilityOwner for Module {}
3616impl ast::NameOwner for Module {}
3617impl ast::AttrsOwner for Module {}
3618impl ast::DocCommentsOwner for Module {}
3619impl Module {
3620 pub fn mod_kw(&self) -> Option<ModKw> {
3621 support::token(&self.syntax)
3622 }
3623 pub fn item_list(&self) -> Option<ItemList> {
3624 support::child(&self.syntax)
3625 }
3626 pub fn semi(&self) -> Option<Semi> {
3627 support::token(&self.syntax)
3628 }
3629}
3630#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3631pub struct ItemList {
3632 pub(crate) syntax: SyntaxNode,
3633}
3634impl std::fmt::Display for ItemList {
3635 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3636 std::fmt::Display::fmt(self.syntax(), f)
3637 }
3638}
3639impl AstNode for ItemList {
3640 fn can_cast(kind: SyntaxKind) -> bool {
3641 match kind {
3642 ITEM_LIST => true,
3643 _ => false,
3644 }
3645 }
3646 fn cast(syntax: SyntaxNode) -> Option<Self> {
3647 if Self::can_cast(syntax.kind()) {
3648 Some(Self { syntax })
3649 } else {
3650 None
3651 }
3652 }
3653 fn syntax(&self) -> &SyntaxNode {
3654 &self.syntax
3655 }
3656}
3657impl ast::FnDefOwner for ItemList {}
3658impl ast::ModuleItemOwner for ItemList {}
3659impl ItemList {
3660 pub fn l_curly(&self) -> Option<LCurly> {
3661 support::token(&self.syntax)
3662 }
3663 pub fn impl_items(&self) -> AstChildren<ImplItem> {
3664 support::children(&self.syntax)
3665 }
3666 pub fn r_curly(&self) -> Option<RCurly> {
3667 support::token(&self.syntax)
3668 }
3669}
3670#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3671pub struct ConstDef {
3672 pub(crate) syntax: SyntaxNode,
3673}
3674impl std::fmt::Display for ConstDef {
3675 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3676 std::fmt::Display::fmt(self.syntax(), f)
3677 }
3678}
3679impl AstNode for ConstDef {
3680 fn can_cast(kind: SyntaxKind) -> bool {
3681 match kind {
3682 CONST_DEF => true,
3683 _ => false,
3684 }
3685 }
3686 fn cast(syntax: SyntaxNode) -> Option<Self> {
3687 if Self::can_cast(syntax.kind()) {
3688 Some(Self { syntax })
3689 } else {
3690 None
3691 }
3692 }
3693 fn syntax(&self) -> &SyntaxNode {
3694 &self.syntax
3695 }
3696}
3697impl ast::VisibilityOwner for ConstDef {}
3698impl ast::NameOwner for ConstDef {}
3699impl ast::TypeParamsOwner for ConstDef {}
3700impl ast::AttrsOwner for ConstDef {}
3701impl ast::DocCommentsOwner for ConstDef {}
3702impl ast::TypeAscriptionOwner for ConstDef {}
3703impl ConstDef {
3704 pub fn default_kw(&self) -> Option<DefaultKw> {
3705 support::token(&self.syntax)
3706 }
3707 pub fn const_kw(&self) -> Option<ConstKw> {
3708 support::token(&self.syntax)
3709 }
3710 pub fn eq(&self) -> Option<Eq> {
3711 support::token(&self.syntax)
3712 }
3713 pub fn body(&self) -> Option<Expr> {
3714 support::child(&self.syntax)
3715 }
3716 pub fn semi(&self) -> Option<Semi> {
3717 support::token(&self.syntax)
3718 }
3719}
3720#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3721pub struct StaticDef {
3722 pub(crate) syntax: SyntaxNode,
3723}
3724impl std::fmt::Display for StaticDef {
3725 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3726 std::fmt::Display::fmt(self.syntax(), f)
3727 }
3728}
3729impl AstNode for StaticDef {
3730 fn can_cast(kind: SyntaxKind) -> bool {
3731 match kind {
3732 STATIC_DEF => true,
3733 _ => false,
3734 }
3735 }
3736 fn cast(syntax: SyntaxNode) -> Option<Self> {
3737 if Self::can_cast(syntax.kind()) {
3738 Some(Self { syntax })
3739 } else {
3740 None
3741 }
3742 }
3743 fn syntax(&self) -> &SyntaxNode {
3744 &self.syntax
3745 }
3746}
3747impl ast::VisibilityOwner for StaticDef {}
3748impl ast::NameOwner for StaticDef {}
3749impl ast::TypeParamsOwner for StaticDef {}
3750impl ast::AttrsOwner for StaticDef {}
3751impl ast::DocCommentsOwner for StaticDef {}
3752impl ast::TypeAscriptionOwner for StaticDef {}
3753impl StaticDef {
3754 pub fn static_kw(&self) -> Option<StaticKw> {
3755 support::token(&self.syntax)
3756 }
3757 pub fn mut_kw(&self) -> Option<MutKw> {
3758 support::token(&self.syntax)
3759 }
3760 pub fn eq(&self) -> Option<Eq> {
3761 support::token(&self.syntax)
3762 }
3763 pub fn body(&self) -> Option<Expr> {
3764 support::child(&self.syntax)
3765 }
3766 pub fn semi(&self) -> Option<Semi> {
3767 support::token(&self.syntax)
3768 }
3769}
3770#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3771pub struct TypeAliasDef {
3772 pub(crate) syntax: SyntaxNode,
3773}
3774impl std::fmt::Display for TypeAliasDef {
3775 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3776 std::fmt::Display::fmt(self.syntax(), f)
3777 }
3778}
3779impl AstNode for TypeAliasDef {
3780 fn can_cast(kind: SyntaxKind) -> bool {
3781 match kind {
3782 TYPE_ALIAS_DEF => true,
3783 _ => false,
3784 }
3785 }
3786 fn cast(syntax: SyntaxNode) -> Option<Self> {
3787 if Self::can_cast(syntax.kind()) {
3788 Some(Self { syntax })
3789 } else {
3790 None
3791 }
3792 }
3793 fn syntax(&self) -> &SyntaxNode {
3794 &self.syntax
3795 }
3796}
3797impl ast::VisibilityOwner for TypeAliasDef {}
3798impl ast::NameOwner for TypeAliasDef {}
3799impl ast::TypeParamsOwner for TypeAliasDef {}
3800impl ast::AttrsOwner for TypeAliasDef {}
3801impl ast::DocCommentsOwner for TypeAliasDef {}
3802impl ast::TypeBoundsOwner for TypeAliasDef {}
3803impl TypeAliasDef {
3804 pub fn default_kw(&self) -> Option<DefaultKw> {
3805 support::token(&self.syntax)
3806 }
3807 pub fn type_kw(&self) -> Option<TypeKw> {
3808 support::token(&self.syntax)
3809 }
3810 pub fn eq(&self) -> Option<Eq> {
3811 support::token(&self.syntax)
3812 }
3813 pub fn type_ref(&self) -> Option<TypeRef> {
3814 support::child(&self.syntax)
3815 }
3816 pub fn semi(&self) -> Option<Semi> {
3817 support::token(&self.syntax)
3818 }
3819}
3820#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3821pub struct ImplDef {
3822 pub(crate) syntax: SyntaxNode,
3823}
3824impl std::fmt::Display for ImplDef {
3825 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3826 std::fmt::Display::fmt(self.syntax(), f)
3827 }
3828}
3829impl AstNode for ImplDef {
3830 fn can_cast(kind: SyntaxKind) -> bool {
3831 match kind {
3832 IMPL_DEF => true,
3833 _ => false,
3834 }
3835 }
3836 fn cast(syntax: SyntaxNode) -> Option<Self> {
3837 if Self::can_cast(syntax.kind()) {
3838 Some(Self { syntax })
3839 } else {
3840 None
3841 }
3842 }
3843 fn syntax(&self) -> &SyntaxNode {
3844 &self.syntax
3845 }
3846}
3847impl ast::TypeParamsOwner for ImplDef {}
3848impl ast::AttrsOwner for ImplDef {}
3849impl ImplDef {
3850 pub fn default_kw(&self) -> Option<DefaultKw> {
3851 support::token(&self.syntax)
3852 }
3853 pub fn const_kw(&self) -> Option<ConstKw> {
3854 support::token(&self.syntax)
3855 }
3856 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
3857 support::token(&self.syntax)
3858 }
3859 pub fn impl_kw(&self) -> Option<ImplKw> {
3860 support::token(&self.syntax)
3861 }
3862 pub fn excl(&self) -> Option<Excl> {
3863 support::token(&self.syntax)
3864 }
3865 pub fn for_kw(&self) -> Option<ForKw> {
3866 support::token(&self.syntax)
3867 }
3868 pub fn item_list(&self) -> Option<ItemList> {
3869 support::child(&self.syntax)
3870 }
3871}
3872#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3873pub struct ParenType {
3874 pub(crate) syntax: SyntaxNode,
3875}
3876impl std::fmt::Display for ParenType {
3877 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3878 std::fmt::Display::fmt(self.syntax(), f)
3879 }
3880}
3881impl AstNode for ParenType {
3882 fn can_cast(kind: SyntaxKind) -> bool {
3883 match kind {
3884 PAREN_TYPE => true,
3885 _ => false,
3886 }
3887 }
3888 fn cast(syntax: SyntaxNode) -> Option<Self> {
3889 if Self::can_cast(syntax.kind()) {
3890 Some(Self { syntax })
3891 } else {
3892 None
3893 }
3894 }
3895 fn syntax(&self) -> &SyntaxNode {
3896 &self.syntax
3897 }
3898}
3899impl ParenType {
3900 pub fn l_paren(&self) -> Option<LParen> {
3901 support::token(&self.syntax)
3902 }
3903 pub fn type_ref(&self) -> Option<TypeRef> {
3904 support::child(&self.syntax)
3905 }
3906 pub fn r_paren(&self) -> Option<RParen> {
3907 support::token(&self.syntax)
3908 }
3909}
3910#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3911pub struct TupleType {
3912 pub(crate) syntax: SyntaxNode,
3913}
3914impl std::fmt::Display for TupleType {
3915 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3916 std::fmt::Display::fmt(self.syntax(), f)
3917 }
3918}
3919impl AstNode for TupleType {
3920 fn can_cast(kind: SyntaxKind) -> bool {
3921 match kind {
3922 TUPLE_TYPE => true,
3923 _ => false,
3924 }
3925 }
3926 fn cast(syntax: SyntaxNode) -> Option<Self> {
3927 if Self::can_cast(syntax.kind()) {
3928 Some(Self { syntax })
3929 } else {
3930 None
3931 }
3932 }
3933 fn syntax(&self) -> &SyntaxNode {
3934 &self.syntax
3935 }
3936}
3937impl TupleType {
3938 pub fn l_paren(&self) -> Option<LParen> {
3939 support::token(&self.syntax)
3940 }
3941 pub fn fields(&self) -> AstChildren<TypeRef> {
3942 support::children(&self.syntax)
3943 }
3944 pub fn r_paren(&self) -> Option<RParen> {
3945 support::token(&self.syntax)
3946 }
3947}
3948#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3949pub struct NeverType {
3950 pub(crate) syntax: SyntaxNode,
3951}
3952impl std::fmt::Display for NeverType {
3953 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3954 std::fmt::Display::fmt(self.syntax(), f)
3955 }
3956}
3957impl AstNode for NeverType {
3958 fn can_cast(kind: SyntaxKind) -> bool {
3959 match kind {
3960 NEVER_TYPE => true,
3961 _ => false,
3962 }
3963 }
3964 fn cast(syntax: SyntaxNode) -> Option<Self> {
3965 if Self::can_cast(syntax.kind()) {
3966 Some(Self { syntax })
3967 } else {
3968 None
3969 }
3970 }
3971 fn syntax(&self) -> &SyntaxNode {
3972 &self.syntax
3973 }
3974}
3975impl NeverType {
3976 pub fn excl(&self) -> Option<Excl> {
3977 support::token(&self.syntax)
3978 }
3979}
3980#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3981pub struct PathType {
3982 pub(crate) syntax: SyntaxNode,
3983}
3984impl std::fmt::Display for PathType {
3985 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3986 std::fmt::Display::fmt(self.syntax(), f)
3987 }
3988}
3989impl AstNode for PathType {
3990 fn can_cast(kind: SyntaxKind) -> bool {
3991 match kind {
3992 PATH_TYPE => true,
3993 _ => false,
3994 }
3995 }
3996 fn cast(syntax: SyntaxNode) -> Option<Self> {
3997 if Self::can_cast(syntax.kind()) {
3998 Some(Self { syntax })
3999 } else {
4000 None
4001 }
4002 }
4003 fn syntax(&self) -> &SyntaxNode {
4004 &self.syntax
4005 }
4006}
4007impl PathType {
4008 pub fn path(&self) -> Option<Path> {
4009 support::child(&self.syntax)
4010 }
4011}
4012#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4013pub struct PointerType {
4014 pub(crate) syntax: SyntaxNode,
4015}
4016impl std::fmt::Display for PointerType {
4017 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4018 std::fmt::Display::fmt(self.syntax(), f)
4019 }
4020}
4021impl AstNode for PointerType {
4022 fn can_cast(kind: SyntaxKind) -> bool {
4023 match kind {
4024 POINTER_TYPE => true,
4025 _ => false,
4026 }
4027 }
4028 fn cast(syntax: SyntaxNode) -> Option<Self> {
4029 if Self::can_cast(syntax.kind()) {
4030 Some(Self { syntax })
4031 } else {
4032 None
4033 }
4034 }
4035 fn syntax(&self) -> &SyntaxNode {
4036 &self.syntax
4037 }
4038}
4039impl PointerType {
4040 pub fn star(&self) -> Option<Star> {
4041 support::token(&self.syntax)
4042 }
4043 pub fn const_kw(&self) -> Option<ConstKw> {
4044 support::token(&self.syntax)
4045 }
4046 pub fn type_ref(&self) -> Option<TypeRef> {
4047 support::child(&self.syntax)
4048 }
4049}
4050#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4051pub struct ArrayType {
4052 pub(crate) syntax: SyntaxNode,
4053}
4054impl std::fmt::Display for ArrayType {
4055 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4056 std::fmt::Display::fmt(self.syntax(), f)
4057 }
4058}
4059impl AstNode for ArrayType {
4060 fn can_cast(kind: SyntaxKind) -> bool {
4061 match kind {
4062 ARRAY_TYPE => true,
4063 _ => false,
4064 }
4065 }
4066 fn cast(syntax: SyntaxNode) -> Option<Self> {
4067 if Self::can_cast(syntax.kind()) {
4068 Some(Self { syntax })
4069 } else {
4070 None
4071 }
4072 }
4073 fn syntax(&self) -> &SyntaxNode {
4074 &self.syntax
4075 }
4076}
4077impl ArrayType {
4078 pub fn l_brack(&self) -> Option<LBrack> {
4079 support::token(&self.syntax)
4080 }
4081 pub fn type_ref(&self) -> Option<TypeRef> {
4082 support::child(&self.syntax)
4083 }
4084 pub fn semi(&self) -> Option<Semi> {
4085 support::token(&self.syntax)
4086 }
4087 pub fn expr(&self) -> Option<Expr> {
4088 support::child(&self.syntax)
4089 }
4090 pub fn r_brack(&self) -> Option<RBrack> {
4091 support::token(&self.syntax)
4092 }
4093}
4094#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4095pub struct SliceType {
4096 pub(crate) syntax: SyntaxNode,
4097}
4098impl std::fmt::Display for SliceType {
4099 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4100 std::fmt::Display::fmt(self.syntax(), f)
4101 }
4102}
4103impl AstNode for SliceType {
4104 fn can_cast(kind: SyntaxKind) -> bool {
4105 match kind {
4106 SLICE_TYPE => true,
4107 _ => false,
4108 }
4109 }
4110 fn cast(syntax: SyntaxNode) -> Option<Self> {
4111 if Self::can_cast(syntax.kind()) {
4112 Some(Self { syntax })
4113 } else {
4114 None
4115 }
4116 }
4117 fn syntax(&self) -> &SyntaxNode {
4118 &self.syntax
4119 }
4120}
4121impl SliceType {
4122 pub fn l_brack(&self) -> Option<LBrack> {
4123 support::token(&self.syntax)
4124 }
4125 pub fn type_ref(&self) -> Option<TypeRef> {
4126 support::child(&self.syntax)
4127 }
4128 pub fn r_brack(&self) -> Option<RBrack> {
4129 support::token(&self.syntax)
4130 }
4131}
4132#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4133pub struct ReferenceType {
4134 pub(crate) syntax: SyntaxNode,
4135}
4136impl std::fmt::Display for ReferenceType {
4137 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4138 std::fmt::Display::fmt(self.syntax(), f)
4139 }
4140}
4141impl AstNode for ReferenceType {
4142 fn can_cast(kind: SyntaxKind) -> bool {
4143 match kind {
4144 REFERENCE_TYPE => true,
4145 _ => false,
4146 }
4147 }
4148 fn cast(syntax: SyntaxNode) -> Option<Self> {
4149 if Self::can_cast(syntax.kind()) {
4150 Some(Self { syntax })
4151 } else {
4152 None
4153 }
4154 }
4155 fn syntax(&self) -> &SyntaxNode {
4156 &self.syntax
4157 }
4158}
4159impl ReferenceType {
4160 pub fn amp(&self) -> Option<Amp> {
4161 support::token(&self.syntax)
4162 }
4163 pub fn lifetime(&self) -> Option<Lifetime> {
4164 support::token(&self.syntax)
4165 }
4166 pub fn mut_kw(&self) -> Option<MutKw> {
4167 support::token(&self.syntax)
4168 }
4169 pub fn type_ref(&self) -> Option<TypeRef> {
4170 support::child(&self.syntax)
4171 }
4172}
4173#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4174pub struct PlaceholderType {
4175 pub(crate) syntax: SyntaxNode,
4176}
4177impl std::fmt::Display for PlaceholderType {
4178 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4179 std::fmt::Display::fmt(self.syntax(), f)
4180 }
4181}
4182impl AstNode for PlaceholderType {
4183 fn can_cast(kind: SyntaxKind) -> bool {
4184 match kind {
4185 PLACEHOLDER_TYPE => true,
4186 _ => false,
4187 }
4188 }
4189 fn cast(syntax: SyntaxNode) -> Option<Self> {
4190 if Self::can_cast(syntax.kind()) {
4191 Some(Self { syntax })
4192 } else {
4193 None
4194 }
4195 }
4196 fn syntax(&self) -> &SyntaxNode {
4197 &self.syntax
4198 }
4199}
4200impl PlaceholderType {
4201 pub fn underscore(&self) -> Option<Underscore> {
4202 support::token(&self.syntax)
4203 }
4204}
4205#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4206pub struct FnPointerType {
4207 pub(crate) syntax: SyntaxNode,
4208}
4209impl std::fmt::Display for FnPointerType {
4210 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4211 std::fmt::Display::fmt(self.syntax(), f)
4212 }
4213}
4214impl AstNode for FnPointerType {
4215 fn can_cast(kind: SyntaxKind) -> bool {
4216 match kind {
4217 FN_POINTER_TYPE => true,
4218 _ => false,
4219 }
4220 }
4221 fn cast(syntax: SyntaxNode) -> Option<Self> {
4222 if Self::can_cast(syntax.kind()) {
4223 Some(Self { syntax })
4224 } else {
4225 None
4226 }
4227 }
4228 fn syntax(&self) -> &SyntaxNode {
4229 &self.syntax
4230 }
4231}
4232impl FnPointerType {
4233 pub fn abi(&self) -> Option<Abi> {
4234 support::child(&self.syntax)
4235 }
4236 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
4237 support::token(&self.syntax)
4238 }
4239 pub fn fn_kw(&self) -> Option<FnKw> {
4240 support::token(&self.syntax)
4241 }
4242 pub fn param_list(&self) -> Option<ParamList> {
4243 support::child(&self.syntax)
4244 }
4245 pub fn ret_type(&self) -> Option<RetType> {
4246 support::child(&self.syntax)
4247 }
4248}
4249#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4250pub struct ForType {
4251 pub(crate) syntax: SyntaxNode,
4252}
4253impl std::fmt::Display for ForType {
4254 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4255 std::fmt::Display::fmt(self.syntax(), f)
4256 }
4257}
4258impl AstNode for ForType {
4259 fn can_cast(kind: SyntaxKind) -> bool {
4260 match kind {
4261 FOR_TYPE => true,
4262 _ => false,
4263 }
4264 }
4265 fn cast(syntax: SyntaxNode) -> Option<Self> {
4266 if Self::can_cast(syntax.kind()) {
4267 Some(Self { syntax })
4268 } else {
4269 None
4270 }
4271 }
4272 fn syntax(&self) -> &SyntaxNode {
4273 &self.syntax
4274 }
4275}
4276impl ForType {
4277 pub fn for_kw(&self) -> Option<ForKw> {
4278 support::token(&self.syntax)
4279 }
4280 pub fn type_param_list(&self) -> Option<TypeParamList> {
4281 support::child(&self.syntax)
4282 }
4283 pub fn type_ref(&self) -> Option<TypeRef> {
4284 support::child(&self.syntax)
4285 }
4286}
4287#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4288pub struct ImplTraitType {
4289 pub(crate) syntax: SyntaxNode,
4290}
4291impl std::fmt::Display for ImplTraitType {
4292 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4293 std::fmt::Display::fmt(self.syntax(), f)
4294 }
4295}
4296impl AstNode for ImplTraitType {
4297 fn can_cast(kind: SyntaxKind) -> bool {
4298 match kind {
4299 IMPL_TRAIT_TYPE => true,
4300 _ => false,
4301 }
4302 }
4303 fn cast(syntax: SyntaxNode) -> Option<Self> {
4304 if Self::can_cast(syntax.kind()) {
4305 Some(Self { syntax })
4306 } else {
4307 None
4308 }
4309 }
4310 fn syntax(&self) -> &SyntaxNode {
4311 &self.syntax
4312 }
4313}
4314impl ast::TypeBoundsOwner for ImplTraitType {}
4315impl ImplTraitType {
4316 pub fn impl_kw(&self) -> Option<ImplKw> {
4317 support::token(&self.syntax)
4318 }
4319}
4320#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4321pub struct DynTraitType {
4322 pub(crate) syntax: SyntaxNode,
4323}
4324impl std::fmt::Display for DynTraitType {
4325 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4326 std::fmt::Display::fmt(self.syntax(), f)
4327 }
4328}
4329impl AstNode for DynTraitType {
4330 fn can_cast(kind: SyntaxKind) -> bool {
4331 match kind {
4332 DYN_TRAIT_TYPE => true,
4333 _ => false,
4334 }
4335 }
4336 fn cast(syntax: SyntaxNode) -> Option<Self> {
4337 if Self::can_cast(syntax.kind()) {
4338 Some(Self { syntax })
4339 } else {
4340 None
4341 }
4342 }
4343 fn syntax(&self) -> &SyntaxNode {
4344 &self.syntax
4345 }
4346}
4347impl ast::TypeBoundsOwner for DynTraitType {}
4348impl DynTraitType {
4349 pub fn dyn_kw(&self) -> Option<DynKw> {
4350 support::token(&self.syntax)
4351 }
4352}
4353#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4354pub struct TupleExpr {
4355 pub(crate) syntax: SyntaxNode,
4356}
4357impl std::fmt::Display for TupleExpr {
4358 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4359 std::fmt::Display::fmt(self.syntax(), f)
4360 }
4361}
4362impl AstNode for TupleExpr {
4363 fn can_cast(kind: SyntaxKind) -> bool {
4364 match kind {
4365 TUPLE_EXPR => true,
4366 _ => false,
4367 }
4368 }
4369 fn cast(syntax: SyntaxNode) -> Option<Self> {
4370 if Self::can_cast(syntax.kind()) {
4371 Some(Self { syntax })
4372 } else {
4373 None
4374 }
4375 }
4376 fn syntax(&self) -> &SyntaxNode {
4377 &self.syntax
4378 }
4379}
4380impl ast::AttrsOwner for TupleExpr {}
4381impl TupleExpr {
4382 pub fn l_paren(&self) -> Option<LParen> {
4383 support::token(&self.syntax)
4384 }
4385 pub fn exprs(&self) -> AstChildren<Expr> {
4386 support::children(&self.syntax)
4387 }
4388 pub fn r_paren(&self) -> Option<RParen> {
4389 support::token(&self.syntax)
4390 }
4391}
4392#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4393pub struct ArrayExpr {
4394 pub(crate) syntax: SyntaxNode,
4395}
4396impl std::fmt::Display for ArrayExpr {
4397 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4398 std::fmt::Display::fmt(self.syntax(), f)
4399 }
4400}
4401impl AstNode for ArrayExpr {
4402 fn can_cast(kind: SyntaxKind) -> bool {
4403 match kind {
4404 ARRAY_EXPR => true,
4405 _ => false,
4406 }
4407 }
4408 fn cast(syntax: SyntaxNode) -> Option<Self> {
4409 if Self::can_cast(syntax.kind()) {
4410 Some(Self { syntax })
4411 } else {
4412 None
4413 }
4414 }
4415 fn syntax(&self) -> &SyntaxNode {
4416 &self.syntax
4417 }
4418}
4419impl ast::AttrsOwner for ArrayExpr {}
4420impl ArrayExpr {
4421 pub fn l_brack(&self) -> Option<LBrack> {
4422 support::token(&self.syntax)
4423 }
4424 pub fn exprs(&self) -> AstChildren<Expr> {
4425 support::children(&self.syntax)
4426 }
4427 pub fn semi(&self) -> Option<Semi> {
4428 support::token(&self.syntax)
4429 }
4430 pub fn r_brack(&self) -> Option<RBrack> {
4431 support::token(&self.syntax)
4432 }
4433}
4434#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4435pub struct ParenExpr {
4436 pub(crate) syntax: SyntaxNode,
4437}
4438impl std::fmt::Display for ParenExpr {
4439 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4440 std::fmt::Display::fmt(self.syntax(), f)
4441 }
4442}
4443impl AstNode for ParenExpr {
4444 fn can_cast(kind: SyntaxKind) -> bool {
4445 match kind {
4446 PAREN_EXPR => true,
4447 _ => false,
4448 }
4449 }
4450 fn cast(syntax: SyntaxNode) -> Option<Self> {
4451 if Self::can_cast(syntax.kind()) {
4452 Some(Self { syntax })
4453 } else {
4454 None
4455 }
4456 }
4457 fn syntax(&self) -> &SyntaxNode {
4458 &self.syntax
4459 }
4460}
4461impl ast::AttrsOwner for ParenExpr {}
4462impl ParenExpr {
4463 pub fn l_paren(&self) -> Option<LParen> {
4464 support::token(&self.syntax)
4465 }
4466 pub fn expr(&self) -> Option<Expr> {
4467 support::child(&self.syntax)
4468 }
4469 pub fn r_paren(&self) -> Option<RParen> {
4470 support::token(&self.syntax)
4471 }
4472}
4473#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4474pub struct PathExpr {
4475 pub(crate) syntax: SyntaxNode,
4476}
4477impl std::fmt::Display for PathExpr {
4478 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4479 std::fmt::Display::fmt(self.syntax(), f)
4480 }
4481}
4482impl AstNode for PathExpr {
4483 fn can_cast(kind: SyntaxKind) -> bool {
4484 match kind {
4485 PATH_EXPR => true,
4486 _ => false,
4487 }
4488 }
4489 fn cast(syntax: SyntaxNode) -> Option<Self> {
4490 if Self::can_cast(syntax.kind()) {
4491 Some(Self { syntax })
4492 } else {
4493 None
4494 }
4495 }
4496 fn syntax(&self) -> &SyntaxNode {
4497 &self.syntax
4498 }
4499}
4500impl PathExpr {
4501 pub fn path(&self) -> Option<Path> {
4502 support::child(&self.syntax)
4503 }
4504}
4505#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4506pub struct LambdaExpr {
4507 pub(crate) syntax: SyntaxNode,
4508}
4509impl std::fmt::Display for LambdaExpr {
4510 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4511 std::fmt::Display::fmt(self.syntax(), f)
4512 }
4513}
4514impl AstNode for LambdaExpr {
4515 fn can_cast(kind: SyntaxKind) -> bool {
4516 match kind {
4517 LAMBDA_EXPR => true,
4518 _ => false,
4519 }
4520 }
4521 fn cast(syntax: SyntaxNode) -> Option<Self> {
4522 if Self::can_cast(syntax.kind()) {
4523 Some(Self { syntax })
4524 } else {
4525 None
4526 }
4527 }
4528 fn syntax(&self) -> &SyntaxNode {
4529 &self.syntax
4530 }
4531}
4532impl ast::AttrsOwner for LambdaExpr {}
4533impl LambdaExpr {
4534 pub fn static_kw(&self) -> Option<StaticKw> {
4535 support::token(&self.syntax)
4536 }
4537 pub fn async_kw(&self) -> Option<AsyncKw> {
4538 support::token(&self.syntax)
4539 }
4540 pub fn move_kw(&self) -> Option<MoveKw> {
4541 support::token(&self.syntax)
4542 }
4543 pub fn param_list(&self) -> Option<ParamList> {
4544 support::child(&self.syntax)
4545 }
4546 pub fn ret_type(&self) -> Option<RetType> {
4547 support::child(&self.syntax)
4548 }
4549 pub fn body(&self) -> Option<Expr> {
4550 support::child(&self.syntax)
4551 }
4552}
4553#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4554pub struct IfExpr {
4555 pub(crate) syntax: SyntaxNode,
4556}
4557impl std::fmt::Display for IfExpr {
4558 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4559 std::fmt::Display::fmt(self.syntax(), f)
4560 }
4561}
4562impl AstNode for IfExpr {
4563 fn can_cast(kind: SyntaxKind) -> bool {
4564 match kind {
4565 IF_EXPR => true,
4566 _ => false,
4567 }
4568 }
4569 fn cast(syntax: SyntaxNode) -> Option<Self> {
4570 if Self::can_cast(syntax.kind()) {
4571 Some(Self { syntax })
4572 } else {
4573 None
4574 }
4575 }
4576 fn syntax(&self) -> &SyntaxNode {
4577 &self.syntax
4578 }
4579}
4580impl ast::AttrsOwner for IfExpr {}
4581impl IfExpr {
4582 pub fn if_kw(&self) -> Option<IfKw> {
4583 support::token(&self.syntax)
4584 }
4585 pub fn condition(&self) -> Option<Condition> {
4586 support::child(&self.syntax)
4587 }
4588}
4589#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4590pub struct LoopExpr {
4591 pub(crate) syntax: SyntaxNode,
4592}
4593impl std::fmt::Display for LoopExpr {
4594 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4595 std::fmt::Display::fmt(self.syntax(), f)
4596 }
4597}
4598impl AstNode for LoopExpr {
4599 fn can_cast(kind: SyntaxKind) -> bool {
4600 match kind {
4601 LOOP_EXPR => true,
4602 _ => false,
4603 }
4604 }
4605 fn cast(syntax: SyntaxNode) -> Option<Self> {
4606 if Self::can_cast(syntax.kind()) {
4607 Some(Self { syntax })
4608 } else {
4609 None
4610 }
4611 }
4612 fn syntax(&self) -> &SyntaxNode {
4613 &self.syntax
4614 }
4615}
4616impl ast::AttrsOwner for LoopExpr {}
4617impl ast::LoopBodyOwner for LoopExpr {}
4618impl LoopExpr {
4619 pub fn loop_kw(&self) -> Option<LoopKw> {
4620 support::token(&self.syntax)
4621 }
4622}
4623#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4624pub struct TryBlockExpr {
4625 pub(crate) syntax: SyntaxNode,
4626}
4627impl std::fmt::Display for TryBlockExpr {
4628 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4629 std::fmt::Display::fmt(self.syntax(), f)
4630 }
4631}
4632impl AstNode for TryBlockExpr {
4633 fn can_cast(kind: SyntaxKind) -> bool {
4634 match kind {
4635 TRY_BLOCK_EXPR => true,
4636 _ => false,
4637 }
4638 }
4639 fn cast(syntax: SyntaxNode) -> Option<Self> {
4640 if Self::can_cast(syntax.kind()) {
4641 Some(Self { syntax })
4642 } else {
4643 None
4644 }
4645 }
4646 fn syntax(&self) -> &SyntaxNode {
4647 &self.syntax
4648 }
4649}
4650impl ast::AttrsOwner for TryBlockExpr {}
4651impl TryBlockExpr {
4652 pub fn try_kw(&self) -> Option<TryKw> {
4653 support::token(&self.syntax)
4654 }
4655 pub fn body(&self) -> Option<BlockExpr> {
4656 support::child(&self.syntax)
4657 }
4658}
4659#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4660pub struct ForExpr {
4661 pub(crate) syntax: SyntaxNode,
4662}
4663impl std::fmt::Display for ForExpr {
4664 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4665 std::fmt::Display::fmt(self.syntax(), f)
4666 }
4667}
4668impl AstNode for ForExpr {
4669 fn can_cast(kind: SyntaxKind) -> bool {
4670 match kind {
4671 FOR_EXPR => true,
4672 _ => false,
4673 }
4674 }
4675 fn cast(syntax: SyntaxNode) -> Option<Self> {
4676 if Self::can_cast(syntax.kind()) {
4677 Some(Self { syntax })
4678 } else {
4679 None
4680 }
4681 }
4682 fn syntax(&self) -> &SyntaxNode {
4683 &self.syntax
4684 }
4685}
4686impl ast::AttrsOwner for ForExpr {}
4687impl ast::LoopBodyOwner for ForExpr {}
4688impl ForExpr {
4689 pub fn for_kw(&self) -> Option<ForKw> {
4690 support::token(&self.syntax)
4691 }
4692 pub fn pat(&self) -> Option<Pat> {
4693 support::child(&self.syntax)
4694 }
4695 pub fn in_kw(&self) -> Option<InKw> {
4696 support::token(&self.syntax)
4697 }
4698 pub fn iterable(&self) -> Option<Expr> {
4699 support::child(&self.syntax)
4700 }
4701}
4702#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4703pub struct WhileExpr {
4704 pub(crate) syntax: SyntaxNode,
4705}
4706impl std::fmt::Display for WhileExpr {
4707 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4708 std::fmt::Display::fmt(self.syntax(), f)
4709 }
4710}
4711impl AstNode for WhileExpr {
4712 fn can_cast(kind: SyntaxKind) -> bool {
4713 match kind {
4714 WHILE_EXPR => true,
4715 _ => false,
4716 }
4717 }
4718 fn cast(syntax: SyntaxNode) -> Option<Self> {
4719 if Self::can_cast(syntax.kind()) {
4720 Some(Self { syntax })
4721 } else {
4722 None
4723 }
4724 }
4725 fn syntax(&self) -> &SyntaxNode {
4726 &self.syntax
4727 }
4728}
4729impl ast::AttrsOwner for WhileExpr {}
4730impl ast::LoopBodyOwner for WhileExpr {}
4731impl WhileExpr {
4732 pub fn while_kw(&self) -> Option<WhileKw> {
4733 support::token(&self.syntax)
4734 }
4735 pub fn condition(&self) -> Option<Condition> {
4736 support::child(&self.syntax)
4737 }
4738}
4739#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4740pub struct ContinueExpr {
4741 pub(crate) syntax: SyntaxNode,
4742}
4743impl std::fmt::Display for ContinueExpr {
4744 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4745 std::fmt::Display::fmt(self.syntax(), f)
4746 }
4747}
4748impl AstNode for ContinueExpr {
4749 fn can_cast(kind: SyntaxKind) -> bool {
4750 match kind {
4751 CONTINUE_EXPR => true,
4752 _ => false,
4753 }
4754 }
4755 fn cast(syntax: SyntaxNode) -> Option<Self> {
4756 if Self::can_cast(syntax.kind()) {
4757 Some(Self { syntax })
4758 } else {
4759 None
4760 }
4761 }
4762 fn syntax(&self) -> &SyntaxNode {
4763 &self.syntax
4764 }
4765}
4766impl ast::AttrsOwner for ContinueExpr {}
4767impl ContinueExpr {
4768 pub fn continue_kw(&self) -> Option<ContinueKw> {
4769 support::token(&self.syntax)
4770 }
4771 pub fn lifetime(&self) -> Option<Lifetime> {
4772 support::token(&self.syntax)
4773 }
4774}
4775#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4776pub struct BreakExpr {
4777 pub(crate) syntax: SyntaxNode,
4778}
4779impl std::fmt::Display for BreakExpr {
4780 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4781 std::fmt::Display::fmt(self.syntax(), f)
4782 }
4783}
4784impl AstNode for BreakExpr {
4785 fn can_cast(kind: SyntaxKind) -> bool {
4786 match kind {
4787 BREAK_EXPR => true,
4788 _ => false,
4789 }
4790 }
4791 fn cast(syntax: SyntaxNode) -> Option<Self> {
4792 if Self::can_cast(syntax.kind()) {
4793 Some(Self { syntax })
4794 } else {
4795 None
4796 }
4797 }
4798 fn syntax(&self) -> &SyntaxNode {
4799 &self.syntax
4800 }
4801}
4802impl ast::AttrsOwner for BreakExpr {}
4803impl BreakExpr {
4804 pub fn break_kw(&self) -> Option<BreakKw> {
4805 support::token(&self.syntax)
4806 }
4807 pub fn lifetime(&self) -> Option<Lifetime> {
4808 support::token(&self.syntax)
4809 }
4810 pub fn expr(&self) -> Option<Expr> {
4811 support::child(&self.syntax)
4812 }
4813}
4814#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4815pub struct Label {
4816 pub(crate) syntax: SyntaxNode,
4817}
4818impl std::fmt::Display for Label {
4819 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4820 std::fmt::Display::fmt(self.syntax(), f)
4821 }
4822}
4823impl AstNode for Label {
4824 fn can_cast(kind: SyntaxKind) -> bool {
4825 match kind {
4826 LABEL => true,
4827 _ => false,
4828 }
4829 }
4830 fn cast(syntax: SyntaxNode) -> Option<Self> {
4831 if Self::can_cast(syntax.kind()) {
4832 Some(Self { syntax })
4833 } else {
4834 None
4835 }
4836 }
4837 fn syntax(&self) -> &SyntaxNode {
4838 &self.syntax
4839 }
4840}
4841impl Label {
4842 pub fn lifetime(&self) -> Option<Lifetime> {
4843 support::token(&self.syntax)
4844 }
4845}
4846#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4847pub struct BlockExpr {
4848 pub(crate) syntax: SyntaxNode,
4849}
4850impl std::fmt::Display for BlockExpr {
4851 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4852 std::fmt::Display::fmt(self.syntax(), f)
4853 }
4854}
4855impl AstNode for BlockExpr {
4856 fn can_cast(kind: SyntaxKind) -> bool {
4857 match kind {
4858 BLOCK_EXPR => true,
4859 _ => false,
4860 }
4861 }
4862 fn cast(syntax: SyntaxNode) -> Option<Self> {
4863 if Self::can_cast(syntax.kind()) {
4864 Some(Self { syntax })
4865 } else {
4866 None
4867 }
4868 }
4869 fn syntax(&self) -> &SyntaxNode {
4870 &self.syntax
4871 }
4872}
4873impl ast::AttrsOwner for BlockExpr {}
4874impl BlockExpr {
4875 pub fn label(&self) -> Option<Label> {
4876 support::child(&self.syntax)
4877 }
4878 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
4879 support::token(&self.syntax)
4880 }
4881 pub fn block(&self) -> Option<Block> {
4882 support::child(&self.syntax)
4883 }
4884}
4885#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4886pub struct ReturnExpr {
4887 pub(crate) syntax: SyntaxNode,
4888}
4889impl std::fmt::Display for ReturnExpr {
4890 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4891 std::fmt::Display::fmt(self.syntax(), f)
4892 }
4893}
4894impl AstNode for ReturnExpr {
4895 fn can_cast(kind: SyntaxKind) -> bool {
4896 match kind {
4897 RETURN_EXPR => true,
4898 _ => false,
4899 }
4900 }
4901 fn cast(syntax: SyntaxNode) -> Option<Self> {
4902 if Self::can_cast(syntax.kind()) {
4903 Some(Self { syntax })
4904 } else {
4905 None
4906 }
4907 }
4908 fn syntax(&self) -> &SyntaxNode {
4909 &self.syntax
4910 }
4911}
4912impl ast::AttrsOwner for ReturnExpr {}
4913impl ReturnExpr {
4914 pub fn expr(&self) -> Option<Expr> {
4915 support::child(&self.syntax)
4916 }
4917}
4918#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4919pub struct CallExpr {
4920 pub(crate) syntax: SyntaxNode,
4921}
4922impl std::fmt::Display for CallExpr {
4923 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4924 std::fmt::Display::fmt(self.syntax(), f)
4925 }
4926}
4927impl AstNode for CallExpr {
4928 fn can_cast(kind: SyntaxKind) -> bool {
4929 match kind {
4930 CALL_EXPR => true,
4931 _ => false,
4932 }
4933 }
4934 fn cast(syntax: SyntaxNode) -> Option<Self> {
4935 if Self::can_cast(syntax.kind()) {
4936 Some(Self { syntax })
4937 } else {
4938 None
4939 }
4940 }
4941 fn syntax(&self) -> &SyntaxNode {
4942 &self.syntax
4943 }
4944}
4945impl ast::ArgListOwner for CallExpr {}
4946impl CallExpr {
4947 pub fn expr(&self) -> Option<Expr> {
4948 support::child(&self.syntax)
4949 }
4950}
4951#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4952pub struct MethodCallExpr {
4953 pub(crate) syntax: SyntaxNode,
4954}
4955impl std::fmt::Display for MethodCallExpr {
4956 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4957 std::fmt::Display::fmt(self.syntax(), f)
4958 }
4959}
4960impl AstNode for MethodCallExpr {
4961 fn can_cast(kind: SyntaxKind) -> bool {
4962 match kind {
4963 METHOD_CALL_EXPR => true,
4964 _ => false,
4965 }
4966 }
4967 fn cast(syntax: SyntaxNode) -> Option<Self> {
4968 if Self::can_cast(syntax.kind()) {
4969 Some(Self { syntax })
4970 } else {
4971 None
4972 }
4973 }
4974 fn syntax(&self) -> &SyntaxNode {
4975 &self.syntax
4976 }
4977}
4978impl ast::AttrsOwner for MethodCallExpr {}
4979impl ast::ArgListOwner for MethodCallExpr {}
4980impl MethodCallExpr {
4981 pub fn expr(&self) -> Option<Expr> {
4982 support::child(&self.syntax)
4983 }
4984 pub fn dot(&self) -> Option<Dot> {
4985 support::token(&self.syntax)
4986 }
4987 pub fn name_ref(&self) -> Option<NameRef> {
4988 support::child(&self.syntax)
4989 }
4990 pub fn type_arg_list(&self) -> Option<TypeArgList> {
4991 support::child(&self.syntax)
4992 }
4993}
4994#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4995pub struct IndexExpr {
4996 pub(crate) syntax: SyntaxNode,
4997}
4998impl std::fmt::Display for IndexExpr {
4999 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5000 std::fmt::Display::fmt(self.syntax(), f)
5001 }
5002}
5003impl AstNode for IndexExpr {
5004 fn can_cast(kind: SyntaxKind) -> bool {
5005 match kind {
5006 INDEX_EXPR => true,
5007 _ => false,
5008 }
5009 }
5010 fn cast(syntax: SyntaxNode) -> Option<Self> {
5011 if Self::can_cast(syntax.kind()) {
5012 Some(Self { syntax })
5013 } else {
5014 None
5015 }
5016 }
5017 fn syntax(&self) -> &SyntaxNode {
5018 &self.syntax
5019 }
5020}
5021impl ast::AttrsOwner for IndexExpr {}
5022impl IndexExpr {
5023 pub fn l_brack(&self) -> Option<LBrack> {
5024 support::token(&self.syntax)
5025 }
5026 pub fn r_brack(&self) -> Option<RBrack> {
5027 support::token(&self.syntax)
5028 }
5029}
5030#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5031pub struct FieldExpr {
5032 pub(crate) syntax: SyntaxNode,
5033}
5034impl std::fmt::Display for FieldExpr {
5035 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5036 std::fmt::Display::fmt(self.syntax(), f)
5037 }
5038}
5039impl AstNode for FieldExpr {
5040 fn can_cast(kind: SyntaxKind) -> bool {
5041 match kind {
5042 FIELD_EXPR => true,
5043 _ => false,
5044 }
5045 }
5046 fn cast(syntax: SyntaxNode) -> Option<Self> {
5047 if Self::can_cast(syntax.kind()) {
5048 Some(Self { syntax })
5049 } else {
5050 None
5051 }
5052 }
5053 fn syntax(&self) -> &SyntaxNode {
5054 &self.syntax
5055 }
5056}
5057impl ast::AttrsOwner for FieldExpr {}
5058impl FieldExpr {
5059 pub fn expr(&self) -> Option<Expr> {
5060 support::child(&self.syntax)
5061 }
5062 pub fn dot(&self) -> Option<Dot> {
5063 support::token(&self.syntax)
5064 }
5065 pub fn name_ref(&self) -> Option<NameRef> {
5066 support::child(&self.syntax)
5067 }
5068}
5069#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5070pub struct AwaitExpr {
5071 pub(crate) syntax: SyntaxNode,
5072}
5073impl std::fmt::Display for AwaitExpr {
5074 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5075 std::fmt::Display::fmt(self.syntax(), f)
5076 }
5077}
5078impl AstNode for AwaitExpr {
5079 fn can_cast(kind: SyntaxKind) -> bool {
5080 match kind {
5081 AWAIT_EXPR => true,
5082 _ => false,
5083 }
5084 }
5085 fn cast(syntax: SyntaxNode) -> Option<Self> {
5086 if Self::can_cast(syntax.kind()) {
5087 Some(Self { syntax })
5088 } else {
5089 None
5090 }
5091 }
5092 fn syntax(&self) -> &SyntaxNode {
5093 &self.syntax
5094 }
5095}
5096impl ast::AttrsOwner for AwaitExpr {}
5097impl AwaitExpr {
5098 pub fn expr(&self) -> Option<Expr> {
5099 support::child(&self.syntax)
5100 }
5101 pub fn dot(&self) -> Option<Dot> {
5102 support::token(&self.syntax)
5103 }
5104 pub fn await_kw(&self) -> Option<AwaitKw> {
5105 support::token(&self.syntax)
5106 }
5107}
5108#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5109pub struct TryExpr {
5110 pub(crate) syntax: SyntaxNode,
5111}
5112impl std::fmt::Display for TryExpr {
5113 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5114 std::fmt::Display::fmt(self.syntax(), f)
5115 }
5116}
5117impl AstNode for TryExpr {
5118 fn can_cast(kind: SyntaxKind) -> bool {
5119 match kind {
5120 TRY_EXPR => true,
5121 _ => false,
5122 }
5123 }
5124 fn cast(syntax: SyntaxNode) -> Option<Self> {
5125 if Self::can_cast(syntax.kind()) {
5126 Some(Self { syntax })
5127 } else {
5128 None
5129 }
5130 }
5131 fn syntax(&self) -> &SyntaxNode {
5132 &self.syntax
5133 }
5134}
5135impl ast::AttrsOwner for TryExpr {}
5136impl TryExpr {
5137 pub fn try_kw(&self) -> Option<TryKw> {
5138 support::token(&self.syntax)
5139 }
5140 pub fn expr(&self) -> Option<Expr> {
5141 support::child(&self.syntax)
5142 }
5143}
5144#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5145pub struct CastExpr {
5146 pub(crate) syntax: SyntaxNode,
5147}
5148impl std::fmt::Display for CastExpr {
5149 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5150 std::fmt::Display::fmt(self.syntax(), f)
5151 }
5152}
5153impl AstNode for CastExpr {
5154 fn can_cast(kind: SyntaxKind) -> bool {
5155 match kind {
5156 CAST_EXPR => true,
5157 _ => false,
5158 }
5159 }
5160 fn cast(syntax: SyntaxNode) -> Option<Self> {
5161 if Self::can_cast(syntax.kind()) {
5162 Some(Self { syntax })
5163 } else {
5164 None
5165 }
5166 }
5167 fn syntax(&self) -> &SyntaxNode {
5168 &self.syntax
5169 }
5170}
5171impl ast::AttrsOwner for CastExpr {}
5172impl CastExpr {
5173 pub fn expr(&self) -> Option<Expr> {
5174 support::child(&self.syntax)
5175 }
5176 pub fn as_kw(&self) -> Option<AsKw> {
5177 support::token(&self.syntax)
5178 }
5179 pub fn type_ref(&self) -> Option<TypeRef> {
5180 support::child(&self.syntax)
5181 }
5182}
5183#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5184pub struct RefExpr {
5185 pub(crate) syntax: SyntaxNode,
5186}
5187impl std::fmt::Display for RefExpr {
5188 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5189 std::fmt::Display::fmt(self.syntax(), f)
5190 }
5191}
5192impl AstNode for RefExpr {
5193 fn can_cast(kind: SyntaxKind) -> bool {
5194 match kind {
5195 REF_EXPR => true,
5196 _ => false,
5197 }
5198 }
5199 fn cast(syntax: SyntaxNode) -> Option<Self> {
5200 if Self::can_cast(syntax.kind()) {
5201 Some(Self { syntax })
5202 } else {
5203 None
5204 }
5205 }
5206 fn syntax(&self) -> &SyntaxNode {
5207 &self.syntax
5208 }
5209}
5210impl ast::AttrsOwner for RefExpr {}
5211impl RefExpr {
5212 pub fn amp(&self) -> Option<Amp> {
5213 support::token(&self.syntax)
5214 }
5215 pub fn raw_kw(&self) -> Option<RawKw> {
5216 support::token(&self.syntax)
5217 }
5218 pub fn mut_kw(&self) -> Option<MutKw> {
5219 support::token(&self.syntax)
5220 }
5221 pub fn expr(&self) -> Option<Expr> {
5222 support::child(&self.syntax)
5223 }
5224}
5225#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5226pub struct PrefixExpr {
5227 pub(crate) syntax: SyntaxNode,
5228}
5229impl std::fmt::Display for PrefixExpr {
5230 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5231 std::fmt::Display::fmt(self.syntax(), f)
5232 }
5233}
5234impl AstNode for PrefixExpr {
5235 fn can_cast(kind: SyntaxKind) -> bool {
5236 match kind {
5237 PREFIX_EXPR => true,
5238 _ => false,
5239 }
5240 }
5241 fn cast(syntax: SyntaxNode) -> Option<Self> {
5242 if Self::can_cast(syntax.kind()) {
5243 Some(Self { syntax })
5244 } else {
5245 None
5246 }
5247 }
5248 fn syntax(&self) -> &SyntaxNode {
5249 &self.syntax
5250 }
5251}
5252impl ast::AttrsOwner for PrefixExpr {}
5253impl PrefixExpr {
5254 pub fn prefix_op(&self) -> Option<PrefixOp> {
5255 support::token(&self.syntax)
5256 }
5257 pub fn expr(&self) -> Option<Expr> {
5258 support::child(&self.syntax)
5259 }
5260}
5261#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5262pub struct BoxExpr {
5263 pub(crate) syntax: SyntaxNode,
5264}
5265impl std::fmt::Display for BoxExpr {
5266 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5267 std::fmt::Display::fmt(self.syntax(), f)
5268 }
5269}
5270impl AstNode for BoxExpr {
5271 fn can_cast(kind: SyntaxKind) -> bool {
5272 match kind {
5273 BOX_EXPR => true,
5274 _ => false,
5275 }
5276 }
5277 fn cast(syntax: SyntaxNode) -> Option<Self> {
5278 if Self::can_cast(syntax.kind()) {
5279 Some(Self { syntax })
5280 } else {
5281 None
5282 }
5283 }
5284 fn syntax(&self) -> &SyntaxNode {
5285 &self.syntax
5286 }
5287}
5288impl ast::AttrsOwner for BoxExpr {}
5289impl BoxExpr {
5290 pub fn box_kw(&self) -> Option<BoxKw> {
5291 support::token(&self.syntax)
5292 }
5293 pub fn expr(&self) -> Option<Expr> {
5294 support::child(&self.syntax)
5295 }
5296}
5297#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5298pub struct RangeExpr {
5299 pub(crate) syntax: SyntaxNode,
5300}
5301impl std::fmt::Display for RangeExpr {
5302 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5303 std::fmt::Display::fmt(self.syntax(), f)
5304 }
5305}
5306impl AstNode for RangeExpr {
5307 fn can_cast(kind: SyntaxKind) -> bool {
5308 match kind {
5309 RANGE_EXPR => true,
5310 _ => false,
5311 }
5312 }
5313 fn cast(syntax: SyntaxNode) -> Option<Self> {
5314 if Self::can_cast(syntax.kind()) {
5315 Some(Self { syntax })
5316 } else {
5317 None
5318 }
5319 }
5320 fn syntax(&self) -> &SyntaxNode {
5321 &self.syntax
5322 }
5323}
5324impl ast::AttrsOwner for RangeExpr {}
5325impl RangeExpr {
5326 pub fn range_op(&self) -> Option<RangeOp> {
5327 support::token(&self.syntax)
5328 }
5329}
5330#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5331pub struct BinExpr {
5332 pub(crate) syntax: SyntaxNode,
5333}
5334impl std::fmt::Display for BinExpr {
5335 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5336 std::fmt::Display::fmt(self.syntax(), f)
5337 }
5338}
5339impl AstNode for BinExpr {
5340 fn can_cast(kind: SyntaxKind) -> bool {
5341 match kind {
5342 BIN_EXPR => true,
5343 _ => false,
5344 }
5345 }
5346 fn cast(syntax: SyntaxNode) -> Option<Self> {
5347 if Self::can_cast(syntax.kind()) {
5348 Some(Self { syntax })
5349 } else {
5350 None
5351 }
5352 }
5353 fn syntax(&self) -> &SyntaxNode {
5354 &self.syntax
5355 }
5356}
5357impl ast::AttrsOwner for BinExpr {}
5358impl BinExpr {
5359 pub fn bin_op(&self) -> Option<BinOp> {
5360 support::token(&self.syntax)
5361 }
5362}
5363#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5364pub struct Literal {
5365 pub(crate) syntax: SyntaxNode,
5366}
5367impl std::fmt::Display for Literal {
5368 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5369 std::fmt::Display::fmt(self.syntax(), f)
5370 }
5371}
5372impl AstNode for Literal {
5373 fn can_cast(kind: SyntaxKind) -> bool {
5374 match kind {
5375 LITERAL => true,
5376 _ => false,
5377 }
5378 }
5379 fn cast(syntax: SyntaxNode) -> Option<Self> {
5380 if Self::can_cast(syntax.kind()) {
5381 Some(Self { syntax })
5382 } else {
5383 None
5384 }
5385 }
5386 fn syntax(&self) -> &SyntaxNode {
5387 &self.syntax
5388 }
5389}
5390impl Literal {
5391 pub fn literal_token(&self) -> Option<LiteralToken> {
5392 support::token(&self.syntax)
5393 }
5394}
5395#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5396pub struct MatchExpr {
5397 pub(crate) syntax: SyntaxNode,
5398}
5399impl std::fmt::Display for MatchExpr {
5400 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5401 std::fmt::Display::fmt(self.syntax(), f)
5402 }
5403}
5404impl AstNode for MatchExpr {
5405 fn can_cast(kind: SyntaxKind) -> bool {
5406 match kind {
5407 MATCH_EXPR => true,
5408 _ => false,
5409 }
5410 }
5411 fn cast(syntax: SyntaxNode) -> Option<Self> {
5412 if Self::can_cast(syntax.kind()) {
5413 Some(Self { syntax })
5414 } else {
5415 None
5416 }
5417 }
5418 fn syntax(&self) -> &SyntaxNode {
5419 &self.syntax
5420 }
5421}
5422impl ast::AttrsOwner for MatchExpr {}
5423impl MatchExpr {
5424 pub fn match_kw(&self) -> Option<MatchKw> {
5425 support::token(&self.syntax)
5426 }
5427 pub fn expr(&self) -> Option<Expr> {
5428 support::child(&self.syntax)
5429 }
5430 pub fn match_arm_list(&self) -> Option<MatchArmList> {
5431 support::child(&self.syntax)
5432 }
5433}
5434#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5435pub struct MatchArmList {
5436 pub(crate) syntax: SyntaxNode,
5437}
5438impl std::fmt::Display for MatchArmList {
5439 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5440 std::fmt::Display::fmt(self.syntax(), f)
5441 }
5442}
5443impl AstNode for MatchArmList {
5444 fn can_cast(kind: SyntaxKind) -> bool {
5445 match kind {
5446 MATCH_ARM_LIST => true,
5447 _ => false,
5448 }
5449 }
5450 fn cast(syntax: SyntaxNode) -> Option<Self> {
5451 if Self::can_cast(syntax.kind()) {
5452 Some(Self { syntax })
5453 } else {
5454 None
5455 }
5456 }
5457 fn syntax(&self) -> &SyntaxNode {
5458 &self.syntax
5459 }
5460}
5461impl ast::AttrsOwner for MatchArmList {}
5462impl MatchArmList {
5463 pub fn l_curly(&self) -> Option<LCurly> {
5464 support::token(&self.syntax)
5465 }
5466 pub fn arms(&self) -> AstChildren<MatchArm> {
5467 support::children(&self.syntax)
5468 }
5469 pub fn r_curly(&self) -> Option<RCurly> {
5470 support::token(&self.syntax)
5471 }
5472}
5473#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5474pub struct MatchArm {
5475 pub(crate) syntax: SyntaxNode,
5476}
5477impl std::fmt::Display for MatchArm {
5478 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5479 std::fmt::Display::fmt(self.syntax(), f)
5480 }
5481}
5482impl AstNode for MatchArm {
5483 fn can_cast(kind: SyntaxKind) -> bool {
5484 match kind {
5485 MATCH_ARM => true,
5486 _ => false,
5487 }
5488 }
5489 fn cast(syntax: SyntaxNode) -> Option<Self> {
5490 if Self::can_cast(syntax.kind()) {
5491 Some(Self { syntax })
5492 } else {
5493 None
5494 }
5495 }
5496 fn syntax(&self) -> &SyntaxNode {
5497 &self.syntax
5498 }
5499}
5500impl ast::AttrsOwner for MatchArm {}
5501impl MatchArm {
5502 pub fn pat(&self) -> Option<Pat> {
5503 support::child(&self.syntax)
5504 }
5505 pub fn guard(&self) -> Option<MatchGuard> {
5506 support::child(&self.syntax)
5507 }
5508 pub fn fat_arrow(&self) -> Option<FatArrow> {
5509 support::token(&self.syntax)
5510 }
5511 pub fn expr(&self) -> Option<Expr> {
5512 support::child(&self.syntax)
5513 }
5514}
5515#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5516pub struct MatchGuard {
5517 pub(crate) syntax: SyntaxNode,
5518}
5519impl std::fmt::Display for MatchGuard {
5520 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5521 std::fmt::Display::fmt(self.syntax(), f)
5522 }
5523}
5524impl AstNode for MatchGuard {
5525 fn can_cast(kind: SyntaxKind) -> bool {
5526 match kind {
5527 MATCH_GUARD => true,
5528 _ => false,
5529 }
5530 }
5531 fn cast(syntax: SyntaxNode) -> Option<Self> {
5532 if Self::can_cast(syntax.kind()) {
5533 Some(Self { syntax })
5534 } else {
5535 None
5536 }
5537 }
5538 fn syntax(&self) -> &SyntaxNode {
5539 &self.syntax
5540 }
5541}
5542impl MatchGuard {
5543 pub fn if_kw(&self) -> Option<IfKw> {
5544 support::token(&self.syntax)
5545 }
5546 pub fn expr(&self) -> Option<Expr> {
5547 support::child(&self.syntax)
5548 }
5549}
5550#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5551pub struct RecordLit {
5552 pub(crate) syntax: SyntaxNode,
5553}
5554impl std::fmt::Display for RecordLit {
5555 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5556 std::fmt::Display::fmt(self.syntax(), f)
5557 }
5558}
5559impl AstNode for RecordLit {
5560 fn can_cast(kind: SyntaxKind) -> bool {
5561 match kind {
5562 RECORD_LIT => true,
5563 _ => false,
5564 }
5565 }
5566 fn cast(syntax: SyntaxNode) -> Option<Self> {
5567 if Self::can_cast(syntax.kind()) {
5568 Some(Self { syntax })
5569 } else {
5570 None
5571 }
5572 }
5573 fn syntax(&self) -> &SyntaxNode {
5574 &self.syntax
5575 }
5576}
5577impl RecordLit {
5578 pub fn path(&self) -> Option<Path> {
5579 support::child(&self.syntax)
5580 }
5581 pub fn record_field_list(&self) -> Option<RecordFieldList> {
5582 support::child(&self.syntax)
5583 }
5584}
5585#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5586pub struct RecordFieldList {
5587 pub(crate) syntax: SyntaxNode,
5588}
5589impl std::fmt::Display for RecordFieldList {
5590 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5591 std::fmt::Display::fmt(self.syntax(), f)
5592 }
5593}
5594impl AstNode for RecordFieldList {
5595 fn can_cast(kind: SyntaxKind) -> bool {
5596 match kind {
5597 RECORD_FIELD_LIST => true,
5598 _ => false,
5599 }
5600 }
5601 fn cast(syntax: SyntaxNode) -> Option<Self> {
5602 if Self::can_cast(syntax.kind()) {
5603 Some(Self { syntax })
5604 } else {
5605 None
5606 }
5607 }
5608 fn syntax(&self) -> &SyntaxNode {
5609 &self.syntax
5610 }
5611}
5612impl RecordFieldList {
5613 pub fn l_curly(&self) -> Option<LCurly> {
5614 support::token(&self.syntax)
5615 }
5616 pub fn fields(&self) -> AstChildren<RecordField> {
5617 support::children(&self.syntax)
5618 }
5619 pub fn dotdot(&self) -> Option<Dotdot> {
5620 support::token(&self.syntax)
5621 }
5622 pub fn spread(&self) -> Option<Expr> {
5623 support::child(&self.syntax)
5624 }
5625 pub fn r_curly(&self) -> Option<RCurly> {
5626 support::token(&self.syntax)
5627 }
5628}
5629#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5630pub struct RecordField {
5631 pub(crate) syntax: SyntaxNode,
5632}
5633impl std::fmt::Display for RecordField {
5634 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5635 std::fmt::Display::fmt(self.syntax(), f)
5636 }
5637}
5638impl AstNode for RecordField {
5639 fn can_cast(kind: SyntaxKind) -> bool {
5640 match kind {
5641 RECORD_FIELD => true,
5642 _ => false,
5643 }
5644 }
5645 fn cast(syntax: SyntaxNode) -> Option<Self> {
5646 if Self::can_cast(syntax.kind()) {
5647 Some(Self { syntax })
5648 } else {
5649 None
5650 }
5651 }
5652 fn syntax(&self) -> &SyntaxNode {
5653 &self.syntax
5654 }
5655}
5656impl ast::AttrsOwner for RecordField {}
5657impl RecordField {
5658 pub fn name_ref(&self) -> Option<NameRef> {
5659 support::child(&self.syntax)
5660 }
5661 pub fn colon(&self) -> Option<Colon> {
5662 support::token(&self.syntax)
5663 }
5664 pub fn expr(&self) -> Option<Expr> {
5665 support::child(&self.syntax)
5666 }
5667}
5668#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5669pub struct OrPat {
5670 pub(crate) syntax: SyntaxNode,
5671}
5672impl std::fmt::Display for OrPat {
5673 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5674 std::fmt::Display::fmt(self.syntax(), f)
5675 }
5676}
5677impl AstNode for OrPat {
5678 fn can_cast(kind: SyntaxKind) -> bool {
5679 match kind {
5680 OR_PAT => true,
5681 _ => false,
5682 }
5683 }
5684 fn cast(syntax: SyntaxNode) -> Option<Self> {
5685 if Self::can_cast(syntax.kind()) {
5686 Some(Self { syntax })
5687 } else {
5688 None
5689 }
5690 }
5691 fn syntax(&self) -> &SyntaxNode {
5692 &self.syntax
5693 }
5694}
5695impl OrPat {
5696 pub fn pats(&self) -> AstChildren<Pat> {
5697 support::children(&self.syntax)
5698 }
5699}
5700#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5701pub struct ParenPat {
5702 pub(crate) syntax: SyntaxNode,
5703}
5704impl std::fmt::Display for ParenPat {
5705 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5706 std::fmt::Display::fmt(self.syntax(), f)
5707 }
5708}
5709impl AstNode for ParenPat {
5710 fn can_cast(kind: SyntaxKind) -> bool {
5711 match kind {
5712 PAREN_PAT => true,
5713 _ => false,
5714 }
5715 }
5716 fn cast(syntax: SyntaxNode) -> Option<Self> {
5717 if Self::can_cast(syntax.kind()) {
5718 Some(Self { syntax })
5719 } else {
5720 None
5721 }
5722 }
5723 fn syntax(&self) -> &SyntaxNode {
5724 &self.syntax
5725 }
5726}
5727impl ParenPat {
5728 pub fn l_paren(&self) -> Option<LParen> {
5729 support::token(&self.syntax)
5730 }
5731 pub fn pat(&self) -> Option<Pat> {
5732 support::child(&self.syntax)
5733 }
5734 pub fn r_paren(&self) -> Option<RParen> {
5735 support::token(&self.syntax)
5736 }
5737}
5738#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5739pub struct RefPat {
5740 pub(crate) syntax: SyntaxNode,
5741}
5742impl std::fmt::Display for RefPat {
5743 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5744 std::fmt::Display::fmt(self.syntax(), f)
5745 }
5746}
5747impl AstNode for RefPat {
5748 fn can_cast(kind: SyntaxKind) -> bool {
5749 match kind {
5750 REF_PAT => true,
5751 _ => false,
5752 }
5753 }
5754 fn cast(syntax: SyntaxNode) -> Option<Self> {
5755 if Self::can_cast(syntax.kind()) {
5756 Some(Self { syntax })
5757 } else {
5758 None
5759 }
5760 }
5761 fn syntax(&self) -> &SyntaxNode {
5762 &self.syntax
5763 }
5764}
5765impl RefPat {
5766 pub fn amp(&self) -> Option<Amp> {
5767 support::token(&self.syntax)
5768 }
5769 pub fn mut_kw(&self) -> Option<MutKw> {
5770 support::token(&self.syntax)
5771 }
5772 pub fn pat(&self) -> Option<Pat> {
5773 support::child(&self.syntax)
5774 }
5775}
5776#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5777pub struct BoxPat {
5778 pub(crate) syntax: SyntaxNode,
5779}
5780impl std::fmt::Display for BoxPat {
5781 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5782 std::fmt::Display::fmt(self.syntax(), f)
5783 }
5784}
5785impl AstNode for BoxPat {
5786 fn can_cast(kind: SyntaxKind) -> bool {
5787 match kind {
5788 BOX_PAT => true,
5789 _ => false,
5790 }
5791 }
5792 fn cast(syntax: SyntaxNode) -> Option<Self> {
5793 if Self::can_cast(syntax.kind()) {
5794 Some(Self { syntax })
5795 } else {
5796 None
5797 }
5798 }
5799 fn syntax(&self) -> &SyntaxNode {
5800 &self.syntax
5801 }
5802}
5803impl BoxPat {
5804 pub fn box_kw(&self) -> Option<BoxKw> {
5805 support::token(&self.syntax)
5806 }
5807 pub fn pat(&self) -> Option<Pat> {
5808 support::child(&self.syntax)
5809 }
5810}
5811#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5812pub struct BindPat {
5813 pub(crate) syntax: SyntaxNode,
5814}
5815impl std::fmt::Display for BindPat {
5816 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5817 std::fmt::Display::fmt(self.syntax(), f)
5818 }
5819}
5820impl AstNode for BindPat {
5821 fn can_cast(kind: SyntaxKind) -> bool {
5822 match kind {
5823 BIND_PAT => true,
5824 _ => false,
5825 }
5826 }
5827 fn cast(syntax: SyntaxNode) -> Option<Self> {
5828 if Self::can_cast(syntax.kind()) {
5829 Some(Self { syntax })
5830 } else {
5831 None
5832 }
5833 }
5834 fn syntax(&self) -> &SyntaxNode {
5835 &self.syntax
5836 }
5837}
5838impl ast::AttrsOwner for BindPat {}
5839impl ast::NameOwner for BindPat {}
5840impl BindPat {
5841 pub fn ref_kw(&self) -> Option<RefKw> {
5842 support::token(&self.syntax)
5843 }
5844 pub fn mut_kw(&self) -> Option<MutKw> {
5845 support::token(&self.syntax)
5846 }
5847 pub fn pat(&self) -> Option<Pat> {
5848 support::child(&self.syntax)
5849 }
5850}
5851#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5852pub struct PlaceholderPat {
5853 pub(crate) syntax: SyntaxNode,
5854}
5855impl std::fmt::Display for PlaceholderPat {
5856 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5857 std::fmt::Display::fmt(self.syntax(), f)
5858 }
5859}
5860impl AstNode for PlaceholderPat {
5861 fn can_cast(kind: SyntaxKind) -> bool {
5862 match kind {
5863 PLACEHOLDER_PAT => true,
5864 _ => false,
5865 }
5866 }
5867 fn cast(syntax: SyntaxNode) -> Option<Self> {
5868 if Self::can_cast(syntax.kind()) {
5869 Some(Self { syntax })
5870 } else {
5871 None
5872 }
5873 }
5874 fn syntax(&self) -> &SyntaxNode {
5875 &self.syntax
5876 }
5877}
5878impl PlaceholderPat {
5879 pub fn underscore(&self) -> Option<Underscore> {
5880 support::token(&self.syntax)
5881 }
5882}
5883#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5884pub struct DotDotPat {
5885 pub(crate) syntax: SyntaxNode,
5886}
5887impl std::fmt::Display for DotDotPat {
5888 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5889 std::fmt::Display::fmt(self.syntax(), f)
5890 }
5891}
5892impl AstNode for DotDotPat {
5893 fn can_cast(kind: SyntaxKind) -> bool {
5894 match kind {
5895 DOT_DOT_PAT => true,
5896 _ => false,
5897 }
5898 }
5899 fn cast(syntax: SyntaxNode) -> Option<Self> {
5900 if Self::can_cast(syntax.kind()) {
5901 Some(Self { syntax })
5902 } else {
5903 None
5904 }
5905 }
5906 fn syntax(&self) -> &SyntaxNode {
5907 &self.syntax
5908 }
5909}
5910impl DotDotPat {
5911 pub fn dotdot(&self) -> Option<Dotdot> {
5912 support::token(&self.syntax)
5913 }
5914}
5915#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5916pub struct PathPat {
5917 pub(crate) syntax: SyntaxNode,
5918}
5919impl std::fmt::Display for PathPat {
5920 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5921 std::fmt::Display::fmt(self.syntax(), f)
5922 }
5923}
5924impl AstNode for PathPat {
5925 fn can_cast(kind: SyntaxKind) -> bool {
5926 match kind {
5927 PATH_PAT => true,
5928 _ => false,
5929 }
5930 }
5931 fn cast(syntax: SyntaxNode) -> Option<Self> {
5932 if Self::can_cast(syntax.kind()) {
5933 Some(Self { syntax })
5934 } else {
5935 None
5936 }
5937 }
5938 fn syntax(&self) -> &SyntaxNode {
5939 &self.syntax
5940 }
5941}
5942impl PathPat {
5943 pub fn path(&self) -> Option<Path> {
5944 support::child(&self.syntax)
5945 }
5946}
5947#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5948pub struct SlicePat {
5949 pub(crate) syntax: SyntaxNode,
5950}
5951impl std::fmt::Display for SlicePat {
5952 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5953 std::fmt::Display::fmt(self.syntax(), f)
5954 }
5955}
5956impl AstNode for SlicePat {
5957 fn can_cast(kind: SyntaxKind) -> bool {
5958 match kind {
5959 SLICE_PAT => true,
5960 _ => false,
5961 }
5962 }
5963 fn cast(syntax: SyntaxNode) -> Option<Self> {
5964 if Self::can_cast(syntax.kind()) {
5965 Some(Self { syntax })
5966 } else {
5967 None
5968 }
5969 }
5970 fn syntax(&self) -> &SyntaxNode {
5971 &self.syntax
5972 }
5973}
5974impl SlicePat {
5975 pub fn l_brack(&self) -> Option<LBrack> {
5976 support::token(&self.syntax)
5977 }
5978 pub fn args(&self) -> AstChildren<Pat> {
5979 support::children(&self.syntax)
5980 }
5981 pub fn r_brack(&self) -> Option<RBrack> {
5982 support::token(&self.syntax)
5983 }
5984}
5985#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5986pub struct RangePat {
5987 pub(crate) syntax: SyntaxNode,
5988}
5989impl std::fmt::Display for RangePat {
5990 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5991 std::fmt::Display::fmt(self.syntax(), f)
5992 }
5993}
5994impl AstNode for RangePat {
5995 fn can_cast(kind: SyntaxKind) -> bool {
5996 match kind {
5997 RANGE_PAT => true,
5998 _ => false,
5999 }
6000 }
6001 fn cast(syntax: SyntaxNode) -> Option<Self> {
6002 if Self::can_cast(syntax.kind()) {
6003 Some(Self { syntax })
6004 } else {
6005 None
6006 }
6007 }
6008 fn syntax(&self) -> &SyntaxNode {
6009 &self.syntax
6010 }
6011}
6012impl RangePat {
6013 pub fn range_separator(&self) -> Option<RangeSeparator> {
6014 support::token(&self.syntax)
6015 }
6016}
6017#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6018pub struct LiteralPat {
6019 pub(crate) syntax: SyntaxNode,
6020}
6021impl std::fmt::Display for LiteralPat {
6022 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6023 std::fmt::Display::fmt(self.syntax(), f)
6024 }
6025}
6026impl AstNode for LiteralPat {
6027 fn can_cast(kind: SyntaxKind) -> bool {
6028 match kind {
6029 LITERAL_PAT => true,
6030 _ => false,
6031 }
6032 }
6033 fn cast(syntax: SyntaxNode) -> Option<Self> {
6034 if Self::can_cast(syntax.kind()) {
6035 Some(Self { syntax })
6036 } else {
6037 None
6038 }
6039 }
6040 fn syntax(&self) -> &SyntaxNode {
6041 &self.syntax
6042 }
6043}
6044impl LiteralPat {
6045 pub fn literal(&self) -> Option<Literal> {
6046 support::child(&self.syntax)
6047 }
6048}
6049#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6050pub struct MacroPat {
6051 pub(crate) syntax: SyntaxNode,
6052}
6053impl std::fmt::Display for MacroPat {
6054 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6055 std::fmt::Display::fmt(self.syntax(), f)
6056 }
6057}
6058impl AstNode for MacroPat {
6059 fn can_cast(kind: SyntaxKind) -> bool {
6060 match kind {
6061 MACRO_PAT => true,
6062 _ => false,
6063 }
6064 }
6065 fn cast(syntax: SyntaxNode) -> Option<Self> {
6066 if Self::can_cast(syntax.kind()) {
6067 Some(Self { syntax })
6068 } else {
6069 None
6070 }
6071 }
6072 fn syntax(&self) -> &SyntaxNode {
6073 &self.syntax
6074 }
6075}
6076impl MacroPat {
6077 pub fn macro_call(&self) -> Option<MacroCall> {
6078 support::child(&self.syntax)
6079 }
6080}
6081#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6082pub struct RecordPat {
6083 pub(crate) syntax: SyntaxNode,
6084}
6085impl std::fmt::Display for RecordPat {
6086 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6087 std::fmt::Display::fmt(self.syntax(), f)
6088 }
6089}
6090impl AstNode for RecordPat {
6091 fn can_cast(kind: SyntaxKind) -> bool {
6092 match kind {
6093 RECORD_PAT => true,
6094 _ => false,
6095 }
6096 }
6097 fn cast(syntax: SyntaxNode) -> Option<Self> {
6098 if Self::can_cast(syntax.kind()) {
6099 Some(Self { syntax })
6100 } else {
6101 None
6102 }
6103 }
6104 fn syntax(&self) -> &SyntaxNode {
6105 &self.syntax
6106 }
6107}
6108impl RecordPat {
6109 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
6110 support::child(&self.syntax)
6111 }
6112 pub fn path(&self) -> Option<Path> {
6113 support::child(&self.syntax)
6114 }
6115}
6116#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6117pub struct RecordFieldPatList {
6118 pub(crate) syntax: SyntaxNode,
6119}
6120impl std::fmt::Display for RecordFieldPatList {
6121 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6122 std::fmt::Display::fmt(self.syntax(), f)
6123 }
6124}
6125impl AstNode for RecordFieldPatList {
6126 fn can_cast(kind: SyntaxKind) -> bool {
6127 match kind {
6128 RECORD_FIELD_PAT_LIST => true,
6129 _ => false,
6130 }
6131 }
6132 fn cast(syntax: SyntaxNode) -> Option<Self> {
6133 if Self::can_cast(syntax.kind()) {
6134 Some(Self { syntax })
6135 } else {
6136 None
6137 }
6138 }
6139 fn syntax(&self) -> &SyntaxNode {
6140 &self.syntax
6141 }
6142}
6143impl RecordFieldPatList {
6144 pub fn l_curly(&self) -> Option<LCurly> {
6145 support::token(&self.syntax)
6146 }
6147 pub fn pats(&self) -> AstChildren<RecordInnerPat> {
6148 support::children(&self.syntax)
6149 }
6150 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
6151 support::children(&self.syntax)
6152 }
6153 pub fn bind_pats(&self) -> AstChildren<BindPat> {
6154 support::children(&self.syntax)
6155 }
6156 pub fn dotdot(&self) -> Option<Dotdot> {
6157 support::token(&self.syntax)
6158 }
6159 pub fn r_curly(&self) -> Option<RCurly> {
6160 support::token(&self.syntax)
6161 }
6162}
6163#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6164pub struct RecordFieldPat {
6165 pub(crate) syntax: SyntaxNode,
6166}
6167impl std::fmt::Display for RecordFieldPat {
6168 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6169 std::fmt::Display::fmt(self.syntax(), f)
6170 }
6171}
6172impl AstNode for RecordFieldPat {
6173 fn can_cast(kind: SyntaxKind) -> bool {
6174 match kind {
6175 RECORD_FIELD_PAT => true,
6176 _ => false,
6177 }
6178 }
6179 fn cast(syntax: SyntaxNode) -> Option<Self> {
6180 if Self::can_cast(syntax.kind()) {
6181 Some(Self { syntax })
6182 } else {
6183 None
6184 }
6185 }
6186 fn syntax(&self) -> &SyntaxNode {
6187 &self.syntax
6188 }
6189}
6190impl ast::AttrsOwner for RecordFieldPat {}
6191impl ast::NameOwner for RecordFieldPat {}
6192impl RecordFieldPat {
6193 pub fn colon(&self) -> Option<Colon> {
6194 support::token(&self.syntax)
6195 }
6196 pub fn pat(&self) -> Option<Pat> {
6197 support::child(&self.syntax)
6198 }
6199}
6200#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6201pub struct TupleStructPat {
6202 pub(crate) syntax: SyntaxNode,
6203}
6204impl std::fmt::Display for TupleStructPat {
6205 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6206 std::fmt::Display::fmt(self.syntax(), f)
6207 }
6208}
6209impl AstNode for TupleStructPat {
6210 fn can_cast(kind: SyntaxKind) -> bool {
6211 match kind {
6212 TUPLE_STRUCT_PAT => true,
6213 _ => false,
6214 }
6215 }
6216 fn cast(syntax: SyntaxNode) -> Option<Self> {
6217 if Self::can_cast(syntax.kind()) {
6218 Some(Self { syntax })
6219 } else {
6220 None
6221 }
6222 }
6223 fn syntax(&self) -> &SyntaxNode {
6224 &self.syntax
6225 }
6226}
6227impl TupleStructPat {
6228 pub fn path(&self) -> Option<Path> {
6229 support::child(&self.syntax)
6230 }
6231 pub fn l_paren(&self) -> Option<LParen> {
6232 support::token(&self.syntax)
6233 }
6234 pub fn args(&self) -> AstChildren<Pat> {
6235 support::children(&self.syntax)
6236 }
6237 pub fn r_paren(&self) -> Option<RParen> {
6238 support::token(&self.syntax)
6239 }
6240}
6241#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6242pub struct TuplePat {
6243 pub(crate) syntax: SyntaxNode,
6244}
6245impl std::fmt::Display for TuplePat {
6246 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6247 std::fmt::Display::fmt(self.syntax(), f)
6248 }
6249}
6250impl AstNode for TuplePat {
6251 fn can_cast(kind: SyntaxKind) -> bool {
6252 match kind {
6253 TUPLE_PAT => true,
6254 _ => false,
6255 }
6256 }
6257 fn cast(syntax: SyntaxNode) -> Option<Self> {
6258 if Self::can_cast(syntax.kind()) {
6259 Some(Self { syntax })
6260 } else {
6261 None
6262 }
6263 }
6264 fn syntax(&self) -> &SyntaxNode {
6265 &self.syntax
6266 }
6267}
6268impl TuplePat {
6269 pub fn l_paren(&self) -> Option<LParen> {
6270 support::token(&self.syntax)
6271 }
6272 pub fn args(&self) -> AstChildren<Pat> {
6273 support::children(&self.syntax)
6274 }
6275 pub fn r_paren(&self) -> Option<RParen> {
6276 support::token(&self.syntax)
6277 }
6278}
6279#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6280pub struct Visibility {
6281 pub(crate) syntax: SyntaxNode,
6282}
6283impl std::fmt::Display for Visibility {
6284 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6285 std::fmt::Display::fmt(self.syntax(), f)
6286 }
6287}
6288impl AstNode for Visibility {
6289 fn can_cast(kind: SyntaxKind) -> bool {
6290 match kind {
6291 VISIBILITY => true,
6292 _ => false,
6293 }
6294 }
6295 fn cast(syntax: SyntaxNode) -> Option<Self> {
6296 if Self::can_cast(syntax.kind()) {
6297 Some(Self { syntax })
6298 } else {
6299 None
6300 }
6301 }
6302 fn syntax(&self) -> &SyntaxNode {
6303 &self.syntax
6304 }
6305}
6306impl Visibility {
6307 pub fn pub_kw(&self) -> Option<PubKw> {
6308 support::token(&self.syntax)
6309 }
6310 pub fn super_kw(&self) -> Option<SuperKw> {
6311 support::token(&self.syntax)
6312 }
6313 pub fn self_kw(&self) -> Option<SelfKw> {
6314 support::token(&self.syntax)
6315 }
6316 pub fn crate_kw(&self) -> Option<CrateKw> {
6317 support::token(&self.syntax)
6318 }
6319}
6320#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6321pub struct Name {
6322 pub(crate) syntax: SyntaxNode,
6323}
6324impl std::fmt::Display for Name {
6325 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6326 std::fmt::Display::fmt(self.syntax(), f)
6327 }
6328}
6329impl AstNode for Name {
6330 fn can_cast(kind: SyntaxKind) -> bool {
6331 match kind {
6332 NAME => true,
6333 _ => false,
6334 }
6335 }
6336 fn cast(syntax: SyntaxNode) -> Option<Self> {
6337 if Self::can_cast(syntax.kind()) {
6338 Some(Self { syntax })
6339 } else {
6340 None
6341 }
6342 }
6343 fn syntax(&self) -> &SyntaxNode {
6344 &self.syntax
6345 }
6346}
6347impl Name {
6348 pub fn ident(&self) -> Option<Ident> {
6349 support::token(&self.syntax)
6350 }
6351}
6352#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6353pub struct NameRef {
6354 pub(crate) syntax: SyntaxNode,
6355}
6356impl std::fmt::Display for NameRef {
6357 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6358 std::fmt::Display::fmt(self.syntax(), f)
6359 }
6360}
6361impl AstNode for NameRef {
6362 fn can_cast(kind: SyntaxKind) -> bool {
6363 match kind {
6364 NAME_REF => true,
6365 _ => false,
6366 }
6367 }
6368 fn cast(syntax: SyntaxNode) -> Option<Self> {
6369 if Self::can_cast(syntax.kind()) {
6370 Some(Self { syntax })
6371 } else {
6372 None
6373 }
6374 }
6375 fn syntax(&self) -> &SyntaxNode {
6376 &self.syntax
6377 }
6378}
6379impl NameRef {
6380 pub fn name_ref_token(&self) -> Option<NameRefToken> {
6381 support::token(&self.syntax)
6382 }
6383}
6384#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6385pub struct MacroCall {
6386 pub(crate) syntax: SyntaxNode,
6387}
6388impl std::fmt::Display for MacroCall {
6389 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6390 std::fmt::Display::fmt(self.syntax(), f)
6391 }
6392}
6393impl AstNode for MacroCall {
6394 fn can_cast(kind: SyntaxKind) -> bool {
6395 match kind {
6396 MACRO_CALL => true,
6397 _ => false,
6398 }
6399 }
6400 fn cast(syntax: SyntaxNode) -> Option<Self> {
6401 if Self::can_cast(syntax.kind()) {
6402 Some(Self { syntax })
6403 } else {
6404 None
6405 }
6406 }
6407 fn syntax(&self) -> &SyntaxNode {
6408 &self.syntax
6409 }
6410}
6411impl ast::NameOwner for MacroCall {}
6412impl ast::AttrsOwner for MacroCall {}
6413impl ast::DocCommentsOwner for MacroCall {}
6414impl MacroCall {
6415 pub fn path(&self) -> Option<Path> {
6416 support::child(&self.syntax)
6417 }
6418 pub fn excl(&self) -> Option<Excl> {
6419 support::token(&self.syntax)
6420 }
6421 pub fn token_tree(&self) -> Option<TokenTree> {
6422 support::child(&self.syntax)
6423 }
6424 pub fn semi(&self) -> Option<Semi> {
6425 support::token(&self.syntax)
6426 }
6427}
6428#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6429pub struct Attr {
6430 pub(crate) syntax: SyntaxNode,
6431}
6432impl std::fmt::Display for Attr {
6433 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6434 std::fmt::Display::fmt(self.syntax(), f)
6435 }
6436}
6437impl AstNode for Attr {
6438 fn can_cast(kind: SyntaxKind) -> bool {
6439 match kind {
6440 ATTR => true,
6441 _ => false,
6442 }
6443 }
6444 fn cast(syntax: SyntaxNode) -> Option<Self> {
6445 if Self::can_cast(syntax.kind()) {
6446 Some(Self { syntax })
6447 } else {
6448 None
6449 }
6450 }
6451 fn syntax(&self) -> &SyntaxNode {
6452 &self.syntax
6453 }
6454}
6455impl Attr {
6456 pub fn pound(&self) -> Option<Pound> {
6457 support::token(&self.syntax)
6458 }
6459 pub fn excl(&self) -> Option<Excl> {
6460 support::token(&self.syntax)
6461 }
6462 pub fn l_brack(&self) -> Option<LBrack> {
6463 support::token(&self.syntax)
6464 }
6465 pub fn path(&self) -> Option<Path> {
6466 support::child(&self.syntax)
6467 }
6468 pub fn eq(&self) -> Option<Eq> {
6469 support::token(&self.syntax)
6470 }
6471 pub fn input(&self) -> Option<AttrInput> {
6472 support::child(&self.syntax)
6473 }
6474 pub fn r_brack(&self) -> Option<RBrack> {
6475 support::token(&self.syntax)
6476 }
6477}
6478#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6479pub struct TokenTree {
6480 pub(crate) syntax: SyntaxNode,
6481}
6482impl std::fmt::Display for TokenTree {
6483 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6484 std::fmt::Display::fmt(self.syntax(), f)
6485 }
6486}
6487impl AstNode for TokenTree {
6488 fn can_cast(kind: SyntaxKind) -> bool {
6489 match kind {
6490 TOKEN_TREE => true,
6491 _ => false,
6492 }
6493 }
6494 fn cast(syntax: SyntaxNode) -> Option<Self> {
6495 if Self::can_cast(syntax.kind()) {
6496 Some(Self { syntax })
6497 } else {
6498 None
6499 }
6500 }
6501 fn syntax(&self) -> &SyntaxNode {
6502 &self.syntax
6503 }
6504}
6505impl TokenTree {}
6506#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6507pub struct TypeParamList {
6508 pub(crate) syntax: SyntaxNode,
6509}
6510impl std::fmt::Display for TypeParamList {
6511 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6512 std::fmt::Display::fmt(self.syntax(), f)
6513 }
6514}
6515impl AstNode for TypeParamList {
6516 fn can_cast(kind: SyntaxKind) -> bool {
6517 match kind {
6518 TYPE_PARAM_LIST => true,
6519 _ => false,
6520 }
6521 }
6522 fn cast(syntax: SyntaxNode) -> Option<Self> {
6523 if Self::can_cast(syntax.kind()) {
6524 Some(Self { syntax })
6525 } else {
6526 None
6527 }
6528 }
6529 fn syntax(&self) -> &SyntaxNode {
6530 &self.syntax
6531 }
6532}
6533impl TypeParamList {
6534 pub fn l_angle(&self) -> Option<LAngle> {
6535 support::token(&self.syntax)
6536 }
6537 pub fn generic_params(&self) -> AstChildren<GenericParam> {
6538 support::children(&self.syntax)
6539 }
6540 pub fn type_params(&self) -> AstChildren<TypeParam> {
6541 support::children(&self.syntax)
6542 }
6543 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> {
6544 support::children(&self.syntax)
6545 }
6546 pub fn const_params(&self) -> AstChildren<ConstParam> {
6547 support::children(&self.syntax)
6548 }
6549 pub fn r_angle(&self) -> Option<RAngle> {
6550 support::token(&self.syntax)
6551 }
6552}
6553#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6554pub struct TypeParam {
6555 pub(crate) syntax: SyntaxNode,
6556}
6557impl std::fmt::Display for TypeParam {
6558 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6559 std::fmt::Display::fmt(self.syntax(), f)
6560 }
6561}
6562impl AstNode for TypeParam {
6563 fn can_cast(kind: SyntaxKind) -> bool {
6564 match kind {
6565 TYPE_PARAM => true,
6566 _ => false,
6567 }
6568 }
6569 fn cast(syntax: SyntaxNode) -> Option<Self> {
6570 if Self::can_cast(syntax.kind()) {
6571 Some(Self { syntax })
6572 } else {
6573 None
6574 }
6575 }
6576 fn syntax(&self) -> &SyntaxNode {
6577 &self.syntax
6578 }
6579}
6580impl ast::NameOwner for TypeParam {}
6581impl ast::AttrsOwner for TypeParam {}
6582impl ast::TypeBoundsOwner for TypeParam {}
6583impl TypeParam {
6584 pub fn eq(&self) -> Option<Eq> {
6585 support::token(&self.syntax)
6586 }
6587 pub fn default_type(&self) -> Option<TypeRef> {
6588 support::child(&self.syntax)
6589 }
6590}
6591#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6592pub struct ConstParam {
6593 pub(crate) syntax: SyntaxNode,
6594}
6595impl std::fmt::Display for ConstParam {
6596 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6597 std::fmt::Display::fmt(self.syntax(), f)
6598 }
6599}
6600impl AstNode for ConstParam {
6601 fn can_cast(kind: SyntaxKind) -> bool {
6602 match kind {
6603 CONST_PARAM => true,
6604 _ => false,
6605 }
6606 }
6607 fn cast(syntax: SyntaxNode) -> Option<Self> {
6608 if Self::can_cast(syntax.kind()) {
6609 Some(Self { syntax })
6610 } else {
6611 None
6612 }
6613 }
6614 fn syntax(&self) -> &SyntaxNode {
6615 &self.syntax
6616 }
6617}
6618impl ast::NameOwner for ConstParam {}
6619impl ast::AttrsOwner for ConstParam {}
6620impl ast::TypeAscriptionOwner for ConstParam {}
6621impl ConstParam {
6622 pub fn eq(&self) -> Option<Eq> {
6623 support::token(&self.syntax)
6624 }
6625 pub fn default_val(&self) -> Option<Expr> {
6626 support::child(&self.syntax)
6627 }
6628}
6629#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6630pub struct LifetimeParam {
6631 pub(crate) syntax: SyntaxNode,
6632}
6633impl std::fmt::Display for LifetimeParam {
6634 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6635 std::fmt::Display::fmt(self.syntax(), f)
6636 }
6637}
6638impl AstNode for LifetimeParam {
6639 fn can_cast(kind: SyntaxKind) -> bool {
6640 match kind {
6641 LIFETIME_PARAM => true,
6642 _ => false,
6643 }
6644 }
6645 fn cast(syntax: SyntaxNode) -> Option<Self> {
6646 if Self::can_cast(syntax.kind()) {
6647 Some(Self { syntax })
6648 } else {
6649 None
6650 }
6651 }
6652 fn syntax(&self) -> &SyntaxNode {
6653 &self.syntax
6654 }
6655}
6656impl ast::AttrsOwner for LifetimeParam {}
6657impl LifetimeParam {
6658 pub fn lifetime(&self) -> Option<Lifetime> {
6659 support::token(&self.syntax)
6660 }
6661}
6662#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6663pub struct TypeBound {
6664 pub(crate) syntax: SyntaxNode,
6665}
6666impl std::fmt::Display for TypeBound {
6667 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6668 std::fmt::Display::fmt(self.syntax(), f)
6669 }
6670}
6671impl AstNode for TypeBound {
6672 fn can_cast(kind: SyntaxKind) -> bool {
6673 match kind {
6674 TYPE_BOUND => true,
6675 _ => false,
6676 }
6677 }
6678 fn cast(syntax: SyntaxNode) -> Option<Self> {
6679 if Self::can_cast(syntax.kind()) {
6680 Some(Self { syntax })
6681 } else {
6682 None
6683 }
6684 }
6685 fn syntax(&self) -> &SyntaxNode {
6686 &self.syntax
6687 }
6688}
6689impl TypeBound {
6690 pub fn lifetime(&self) -> Option<Lifetime> {
6691 support::token(&self.syntax)
6692 }
6693 pub fn const_kw(&self) -> Option<ConstKw> {
6694 support::token(&self.syntax)
6695 }
6696 pub fn type_ref(&self) -> Option<TypeRef> {
6697 support::child(&self.syntax)
6698 }
6699}
6700#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6701pub struct TypeBoundList {
6702 pub(crate) syntax: SyntaxNode,
6703}
6704impl std::fmt::Display for TypeBoundList {
6705 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6706 std::fmt::Display::fmt(self.syntax(), f)
6707 }
6708}
6709impl AstNode for TypeBoundList {
6710 fn can_cast(kind: SyntaxKind) -> bool {
6711 match kind {
6712 TYPE_BOUND_LIST => true,
6713 _ => false,
6714 }
6715 }
6716 fn cast(syntax: SyntaxNode) -> Option<Self> {
6717 if Self::can_cast(syntax.kind()) {
6718 Some(Self { syntax })
6719 } else {
6720 None
6721 }
6722 }
6723 fn syntax(&self) -> &SyntaxNode {
6724 &self.syntax
6725 }
6726}
6727impl TypeBoundList {
6728 pub fn bounds(&self) -> AstChildren<TypeBound> {
6729 support::children(&self.syntax)
6730 }
6731}
6732#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6733pub struct WherePred {
6734 pub(crate) syntax: SyntaxNode,
6735}
6736impl std::fmt::Display for WherePred {
6737 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6738 std::fmt::Display::fmt(self.syntax(), f)
6739 }
6740}
6741impl AstNode for WherePred {
6742 fn can_cast(kind: SyntaxKind) -> bool {
6743 match kind {
6744 WHERE_PRED => true,
6745 _ => false,
6746 }
6747 }
6748 fn cast(syntax: SyntaxNode) -> Option<Self> {
6749 if Self::can_cast(syntax.kind()) {
6750 Some(Self { syntax })
6751 } else {
6752 None
6753 }
6754 }
6755 fn syntax(&self) -> &SyntaxNode {
6756 &self.syntax
6757 }
6758}
6759impl ast::TypeBoundsOwner for WherePred {}
6760impl WherePred {
6761 pub fn lifetime(&self) -> Option<Lifetime> {
6762 support::token(&self.syntax)
6763 }
6764 pub fn type_ref(&self) -> Option<TypeRef> {
6765 support::child(&self.syntax)
6766 }
6767}
6768#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6769pub struct WhereClause {
6770 pub(crate) syntax: SyntaxNode,
6771}
6772impl std::fmt::Display for WhereClause {
6773 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6774 std::fmt::Display::fmt(self.syntax(), f)
6775 }
6776}
6777impl AstNode for WhereClause {
6778 fn can_cast(kind: SyntaxKind) -> bool {
6779 match kind {
6780 WHERE_CLAUSE => true,
6781 _ => false,
6782 }
6783 }
6784 fn cast(syntax: SyntaxNode) -> Option<Self> {
6785 if Self::can_cast(syntax.kind()) {
6786 Some(Self { syntax })
6787 } else {
6788 None
6789 }
6790 }
6791 fn syntax(&self) -> &SyntaxNode {
6792 &self.syntax
6793 }
6794}
6795impl WhereClause {
6796 pub fn where_kw(&self) -> Option<WhereKw> {
6797 support::token(&self.syntax)
6798 }
6799 pub fn predicates(&self) -> AstChildren<WherePred> {
6800 support::children(&self.syntax)
6801 }
6802}
6803#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6804pub struct Abi {
6805 pub(crate) syntax: SyntaxNode,
6806}
6807impl std::fmt::Display for Abi {
6808 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6809 std::fmt::Display::fmt(self.syntax(), f)
6810 }
6811}
6812impl AstNode for Abi {
6813 fn can_cast(kind: SyntaxKind) -> bool {
6814 match kind {
6815 ABI => true,
6816 _ => false,
6817 }
6818 }
6819 fn cast(syntax: SyntaxNode) -> Option<Self> {
6820 if Self::can_cast(syntax.kind()) {
6821 Some(Self { syntax })
6822 } else {
6823 None
6824 }
6825 }
6826 fn syntax(&self) -> &SyntaxNode {
6827 &self.syntax
6828 }
6829}
6830impl Abi {
6831 pub fn string(&self) -> Option<String> {
6832 support::token(&self.syntax)
6833 }
6834}
6835#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6836pub struct ExprStmt {
6837 pub(crate) syntax: SyntaxNode,
6838}
6839impl std::fmt::Display for ExprStmt {
6840 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6841 std::fmt::Display::fmt(self.syntax(), f)
6842 }
6843}
6844impl AstNode for ExprStmt {
6845 fn can_cast(kind: SyntaxKind) -> bool {
6846 match kind {
6847 EXPR_STMT => true,
6848 _ => false,
6849 }
6850 }
6851 fn cast(syntax: SyntaxNode) -> Option<Self> {
6852 if Self::can_cast(syntax.kind()) {
6853 Some(Self { syntax })
6854 } else {
6855 None
6856 }
6857 }
6858 fn syntax(&self) -> &SyntaxNode {
6859 &self.syntax
6860 }
6861}
6862impl ast::AttrsOwner for ExprStmt {}
6863impl ExprStmt {
6864 pub fn expr(&self) -> Option<Expr> {
6865 support::child(&self.syntax)
6866 }
6867 pub fn semi(&self) -> Option<Semi> {
6868 support::token(&self.syntax)
6869 }
6870}
6871#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6872pub struct LetStmt {
6873 pub(crate) syntax: SyntaxNode,
6874}
6875impl std::fmt::Display for LetStmt {
6876 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6877 std::fmt::Display::fmt(self.syntax(), f)
6878 }
6879}
6880impl AstNode for LetStmt {
6881 fn can_cast(kind: SyntaxKind) -> bool {
6882 match kind {
6883 LET_STMT => true,
6884 _ => false,
6885 }
6886 }
6887 fn cast(syntax: SyntaxNode) -> Option<Self> {
6888 if Self::can_cast(syntax.kind()) {
6889 Some(Self { syntax })
6890 } else {
6891 None
6892 }
6893 }
6894 fn syntax(&self) -> &SyntaxNode {
6895 &self.syntax
6896 }
6897}
6898impl ast::AttrsOwner for LetStmt {}
6899impl ast::TypeAscriptionOwner for LetStmt {}
6900impl LetStmt {
6901 pub fn let_kw(&self) -> Option<LetKw> {
6902 support::token(&self.syntax)
6903 }
6904 pub fn pat(&self) -> Option<Pat> {
6905 support::child(&self.syntax)
6906 }
6907 pub fn eq(&self) -> Option<Eq> {
6908 support::token(&self.syntax)
6909 }
6910 pub fn initializer(&self) -> Option<Expr> {
6911 support::child(&self.syntax)
6912 }
6913}
6914#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6915pub struct Condition {
6916 pub(crate) syntax: SyntaxNode,
6917}
6918impl std::fmt::Display for Condition {
6919 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6920 std::fmt::Display::fmt(self.syntax(), f)
6921 }
6922}
6923impl AstNode for Condition {
6924 fn can_cast(kind: SyntaxKind) -> bool {
6925 match kind {
6926 CONDITION => true,
6927 _ => false,
6928 }
6929 }
6930 fn cast(syntax: SyntaxNode) -> Option<Self> {
6931 if Self::can_cast(syntax.kind()) {
6932 Some(Self { syntax })
6933 } else {
6934 None
6935 }
6936 }
6937 fn syntax(&self) -> &SyntaxNode {
6938 &self.syntax
6939 }
6940}
6941impl Condition {
6942 pub fn let_kw(&self) -> Option<LetKw> {
6943 support::token(&self.syntax)
6944 }
6945 pub fn pat(&self) -> Option<Pat> {
6946 support::child(&self.syntax)
6947 }
6948 pub fn eq(&self) -> Option<Eq> {
6949 support::token(&self.syntax)
6950 }
6951 pub fn expr(&self) -> Option<Expr> {
6952 support::child(&self.syntax)
6953 }
6954}
6955#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6956pub struct Block {
6957 pub(crate) syntax: SyntaxNode,
6958}
6959impl std::fmt::Display for Block {
6960 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6961 std::fmt::Display::fmt(self.syntax(), f)
6962 }
6963}
6964impl AstNode for Block {
6965 fn can_cast(kind: SyntaxKind) -> bool {
6966 match kind {
6967 BLOCK => true,
6968 _ => false,
6969 }
6970 }
6971 fn cast(syntax: SyntaxNode) -> Option<Self> {
6972 if Self::can_cast(syntax.kind()) {
6973 Some(Self { syntax })
6974 } else {
6975 None
6976 }
6977 }
6978 fn syntax(&self) -> &SyntaxNode {
6979 &self.syntax
6980 }
6981}
6982impl ast::AttrsOwner for Block {}
6983impl ast::ModuleItemOwner for Block {}
6984impl Block {
6985 pub fn l_curly(&self) -> Option<LCurly> {
6986 support::token(&self.syntax)
6987 }
6988 pub fn statements(&self) -> AstChildren<Stmt> {
6989 support::children(&self.syntax)
6990 }
6991 pub fn expr(&self) -> Option<Expr> {
6992 support::child(&self.syntax)
6993 }
6994 pub fn r_curly(&self) -> Option<RCurly> {
6995 support::token(&self.syntax)
6996 }
6997}
6998#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6999pub struct ParamList {
7000 pub(crate) syntax: SyntaxNode,
7001}
7002impl std::fmt::Display for ParamList {
7003 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7004 std::fmt::Display::fmt(self.syntax(), f)
7005 }
7006}
7007impl AstNode for ParamList {
7008 fn can_cast(kind: SyntaxKind) -> bool {
7009 match kind {
7010 PARAM_LIST => true,
7011 _ => false,
7012 }
7013 }
7014 fn cast(syntax: SyntaxNode) -> Option<Self> {
7015 if Self::can_cast(syntax.kind()) {
7016 Some(Self { syntax })
7017 } else {
7018 None
7019 }
7020 }
7021 fn syntax(&self) -> &SyntaxNode {
7022 &self.syntax
7023 }
7024}
7025impl ParamList {
7026 pub fn l_paren(&self) -> Option<LParen> {
7027 support::token(&self.syntax)
7028 }
7029 pub fn self_param(&self) -> Option<SelfParam> {
7030 support::child(&self.syntax)
7031 }
7032 pub fn params(&self) -> AstChildren<Param> {
7033 support::children(&self.syntax)
7034 }
7035 pub fn r_paren(&self) -> Option<RParen> {
7036 support::token(&self.syntax)
7037 }
7038}
7039#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7040pub struct SelfParam {
7041 pub(crate) syntax: SyntaxNode,
7042}
7043impl std::fmt::Display for SelfParam {
7044 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7045 std::fmt::Display::fmt(self.syntax(), f)
7046 }
7047}
7048impl AstNode for SelfParam {
7049 fn can_cast(kind: SyntaxKind) -> bool {
7050 match kind {
7051 SELF_PARAM => true,
7052 _ => false,
7053 }
7054 }
7055 fn cast(syntax: SyntaxNode) -> Option<Self> {
7056 if Self::can_cast(syntax.kind()) {
7057 Some(Self { syntax })
7058 } else {
7059 None
7060 }
7061 }
7062 fn syntax(&self) -> &SyntaxNode {
7063 &self.syntax
7064 }
7065}
7066impl ast::TypeAscriptionOwner for SelfParam {}
7067impl ast::AttrsOwner for SelfParam {}
7068impl SelfParam {
7069 pub fn amp(&self) -> Option<Amp> {
7070 support::token(&self.syntax)
7071 }
7072 pub fn lifetime(&self) -> Option<Lifetime> {
7073 support::token(&self.syntax)
7074 }
7075 pub fn self_kw(&self) -> Option<SelfKw> {
7076 support::token(&self.syntax)
7077 }
7078}
7079#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7080pub struct Param {
7081 pub(crate) syntax: SyntaxNode,
7082}
7083impl std::fmt::Display for Param {
7084 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7085 std::fmt::Display::fmt(self.syntax(), f)
7086 }
7087}
7088impl AstNode for Param {
7089 fn can_cast(kind: SyntaxKind) -> bool {
7090 match kind {
7091 PARAM => true,
7092 _ => false,
7093 }
7094 }
7095 fn cast(syntax: SyntaxNode) -> Option<Self> {
7096 if Self::can_cast(syntax.kind()) {
7097 Some(Self { syntax })
7098 } else {
7099 None
7100 }
7101 }
7102 fn syntax(&self) -> &SyntaxNode {
7103 &self.syntax
7104 }
7105}
7106impl ast::TypeAscriptionOwner for Param {}
7107impl ast::AttrsOwner for Param {}
7108impl Param {
7109 pub fn pat(&self) -> Option<Pat> {
7110 support::child(&self.syntax)
7111 }
7112 pub fn dotdotdot(&self) -> Option<Dotdotdot> {
7113 support::token(&self.syntax)
7114 }
7115}
7116#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7117pub struct UseItem {
7118 pub(crate) syntax: SyntaxNode,
7119}
7120impl std::fmt::Display for UseItem {
7121 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7122 std::fmt::Display::fmt(self.syntax(), f)
7123 }
7124}
7125impl AstNode for UseItem {
7126 fn can_cast(kind: SyntaxKind) -> bool {
7127 match kind {
7128 USE_ITEM => true,
7129 _ => false,
7130 }
7131 }
7132 fn cast(syntax: SyntaxNode) -> Option<Self> {
7133 if Self::can_cast(syntax.kind()) {
7134 Some(Self { syntax })
7135 } else {
7136 None
7137 }
7138 }
7139 fn syntax(&self) -> &SyntaxNode {
7140 &self.syntax
7141 }
7142}
7143impl ast::AttrsOwner for UseItem {}
7144impl ast::VisibilityOwner for UseItem {}
7145impl UseItem {
7146 pub fn use_kw(&self) -> Option<UseKw> {
7147 support::token(&self.syntax)
7148 }
7149 pub fn use_tree(&self) -> Option<UseTree> {
7150 support::child(&self.syntax)
7151 }
7152}
7153#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7154pub struct UseTree {
7155 pub(crate) syntax: SyntaxNode,
7156}
7157impl std::fmt::Display for UseTree {
7158 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7159 std::fmt::Display::fmt(self.syntax(), f)
7160 }
7161}
7162impl AstNode for UseTree {
7163 fn can_cast(kind: SyntaxKind) -> bool {
7164 match kind {
7165 USE_TREE => true,
7166 _ => false,
7167 }
7168 }
7169 fn cast(syntax: SyntaxNode) -> Option<Self> {
7170 if Self::can_cast(syntax.kind()) {
7171 Some(Self { syntax })
7172 } else {
7173 None
7174 }
7175 }
7176 fn syntax(&self) -> &SyntaxNode {
7177 &self.syntax
7178 }
7179}
7180impl UseTree {
7181 pub fn path(&self) -> Option<Path> {
7182 support::child(&self.syntax)
7183 }
7184 pub fn star(&self) -> Option<Star> {
7185 support::token(&self.syntax)
7186 }
7187 pub fn use_tree_list(&self) -> Option<UseTreeList> {
7188 support::child(&self.syntax)
7189 }
7190 pub fn alias(&self) -> Option<Alias> {
7191 support::child(&self.syntax)
7192 }
7193}
7194#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7195pub struct Alias {
7196 pub(crate) syntax: SyntaxNode,
7197}
7198impl std::fmt::Display for Alias {
7199 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7200 std::fmt::Display::fmt(self.syntax(), f)
7201 }
7202}
7203impl AstNode for Alias {
7204 fn can_cast(kind: SyntaxKind) -> bool {
7205 match kind {
7206 ALIAS => true,
7207 _ => false,
7208 }
7209 }
7210 fn cast(syntax: SyntaxNode) -> Option<Self> {
7211 if Self::can_cast(syntax.kind()) {
7212 Some(Self { syntax })
7213 } else {
7214 None
7215 }
7216 }
7217 fn syntax(&self) -> &SyntaxNode {
7218 &self.syntax
7219 }
7220}
7221impl ast::NameOwner for Alias {}
7222impl Alias {
7223 pub fn as_kw(&self) -> Option<AsKw> {
7224 support::token(&self.syntax)
7225 }
7226}
7227#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7228pub struct UseTreeList {
7229 pub(crate) syntax: SyntaxNode,
7230}
7231impl std::fmt::Display for UseTreeList {
7232 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7233 std::fmt::Display::fmt(self.syntax(), f)
7234 }
7235}
7236impl AstNode for UseTreeList {
7237 fn can_cast(kind: SyntaxKind) -> bool {
7238 match kind {
7239 USE_TREE_LIST => true,
7240 _ => false,
7241 }
7242 }
7243 fn cast(syntax: SyntaxNode) -> Option<Self> {
7244 if Self::can_cast(syntax.kind()) {
7245 Some(Self { syntax })
7246 } else {
7247 None
7248 }
7249 }
7250 fn syntax(&self) -> &SyntaxNode {
7251 &self.syntax
7252 }
7253}
7254impl UseTreeList {
7255 pub fn l_curly(&self) -> Option<LCurly> {
7256 support::token(&self.syntax)
7257 }
7258 pub fn use_trees(&self) -> AstChildren<UseTree> {
7259 support::children(&self.syntax)
7260 }
7261 pub fn r_curly(&self) -> Option<RCurly> {
7262 support::token(&self.syntax)
7263 }
7264}
7265#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7266pub struct ExternCrateItem {
7267 pub(crate) syntax: SyntaxNode,
7268}
7269impl std::fmt::Display for ExternCrateItem {
7270 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7271 std::fmt::Display::fmt(self.syntax(), f)
7272 }
7273}
7274impl AstNode for ExternCrateItem {
7275 fn can_cast(kind: SyntaxKind) -> bool {
7276 match kind {
7277 EXTERN_CRATE_ITEM => true,
7278 _ => false,
7279 }
7280 }
7281 fn cast(syntax: SyntaxNode) -> Option<Self> {
7282 if Self::can_cast(syntax.kind()) {
7283 Some(Self { syntax })
7284 } else {
7285 None
7286 }
7287 }
7288 fn syntax(&self) -> &SyntaxNode {
7289 &self.syntax
7290 }
7291}
7292impl ast::AttrsOwner for ExternCrateItem {}
7293impl ast::VisibilityOwner for ExternCrateItem {}
7294impl ExternCrateItem {
7295 pub fn extern_kw(&self) -> Option<ExternKw> {
7296 support::token(&self.syntax)
7297 }
7298 pub fn crate_kw(&self) -> Option<CrateKw> {
7299 support::token(&self.syntax)
7300 }
7301 pub fn name_ref(&self) -> Option<NameRef> {
7302 support::child(&self.syntax)
7303 }
7304 pub fn alias(&self) -> Option<Alias> {
7305 support::child(&self.syntax)
7306 }
7307}
7308#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7309pub struct ArgList {
7310 pub(crate) syntax: SyntaxNode,
7311}
7312impl std::fmt::Display for ArgList {
7313 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7314 std::fmt::Display::fmt(self.syntax(), f)
7315 }
7316}
7317impl AstNode for ArgList {
7318 fn can_cast(kind: SyntaxKind) -> bool {
7319 match kind {
7320 ARG_LIST => true,
7321 _ => false,
7322 }
7323 }
7324 fn cast(syntax: SyntaxNode) -> Option<Self> {
7325 if Self::can_cast(syntax.kind()) {
7326 Some(Self { syntax })
7327 } else {
7328 None
7329 }
7330 }
7331 fn syntax(&self) -> &SyntaxNode {
7332 &self.syntax
7333 }
7334}
7335impl ArgList {
7336 pub fn l_paren(&self) -> Option<LParen> {
7337 support::token(&self.syntax)
7338 }
7339 pub fn args(&self) -> AstChildren<Expr> {
7340 support::children(&self.syntax)
7341 }
7342 pub fn r_paren(&self) -> Option<RParen> {
7343 support::token(&self.syntax)
7344 }
7345}
7346#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7347pub struct Path {
7348 pub(crate) syntax: SyntaxNode,
7349}
7350impl std::fmt::Display for Path {
7351 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7352 std::fmt::Display::fmt(self.syntax(), f)
7353 }
7354}
7355impl AstNode for Path {
7356 fn can_cast(kind: SyntaxKind) -> bool {
7357 match kind {
7358 PATH => true,
7359 _ => false,
7360 }
7361 }
7362 fn cast(syntax: SyntaxNode) -> Option<Self> {
7363 if Self::can_cast(syntax.kind()) {
7364 Some(Self { syntax })
7365 } else {
7366 None
7367 }
7368 }
7369 fn syntax(&self) -> &SyntaxNode {
7370 &self.syntax
7371 }
7372}
7373impl Path {
7374 pub fn segment(&self) -> Option<PathSegment> {
7375 support::child(&self.syntax)
7376 }
7377 pub fn qualifier(&self) -> Option<Path> {
7378 support::child(&self.syntax)
7379 }
7380}
7381#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7382pub struct PathSegment {
7383 pub(crate) syntax: SyntaxNode,
7384}
7385impl std::fmt::Display for PathSegment {
7386 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7387 std::fmt::Display::fmt(self.syntax(), f)
7388 }
7389}
7390impl AstNode for PathSegment {
7391 fn can_cast(kind: SyntaxKind) -> bool {
7392 match kind {
7393 PATH_SEGMENT => true,
7394 _ => false,
7395 }
7396 }
7397 fn cast(syntax: SyntaxNode) -> Option<Self> {
7398 if Self::can_cast(syntax.kind()) {
7399 Some(Self { syntax })
7400 } else {
7401 None
7402 }
7403 }
7404 fn syntax(&self) -> &SyntaxNode {
7405 &self.syntax
7406 }
7407}
7408impl PathSegment {
7409 pub fn coloncolon(&self) -> Option<Coloncolon> {
7410 support::token(&self.syntax)
7411 }
7412 pub fn l_angle(&self) -> Option<LAngle> {
7413 support::token(&self.syntax)
7414 }
7415 pub fn name_ref(&self) -> Option<NameRef> {
7416 support::child(&self.syntax)
7417 }
7418 pub fn type_arg_list(&self) -> Option<TypeArgList> {
7419 support::child(&self.syntax)
7420 }
7421 pub fn param_list(&self) -> Option<ParamList> {
7422 support::child(&self.syntax)
7423 }
7424 pub fn ret_type(&self) -> Option<RetType> {
7425 support::child(&self.syntax)
7426 }
7427 pub fn path_type(&self) -> Option<PathType> {
7428 support::child(&self.syntax)
7429 }
7430 pub fn r_angle(&self) -> Option<RAngle> {
7431 support::token(&self.syntax)
7432 }
7433}
7434#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7435pub struct TypeArgList {
7436 pub(crate) syntax: SyntaxNode,
7437}
7438impl std::fmt::Display for TypeArgList {
7439 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7440 std::fmt::Display::fmt(self.syntax(), f)
7441 }
7442}
7443impl AstNode for TypeArgList {
7444 fn can_cast(kind: SyntaxKind) -> bool {
7445 match kind {
7446 TYPE_ARG_LIST => true,
7447 _ => false,
7448 }
7449 }
7450 fn cast(syntax: SyntaxNode) -> Option<Self> {
7451 if Self::can_cast(syntax.kind()) {
7452 Some(Self { syntax })
7453 } else {
7454 None
7455 }
7456 }
7457 fn syntax(&self) -> &SyntaxNode {
7458 &self.syntax
7459 }
7460}
7461impl TypeArgList {
7462 pub fn coloncolon(&self) -> Option<Coloncolon> {
7463 support::token(&self.syntax)
7464 }
7465 pub fn l_angle(&self) -> Option<LAngle> {
7466 support::token(&self.syntax)
7467 }
7468 pub fn generic_args(&self) -> AstChildren<GenericArg> {
7469 support::children(&self.syntax)
7470 }
7471 pub fn type_args(&self) -> AstChildren<TypeArg> {
7472 support::children(&self.syntax)
7473 }
7474 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> {
7475 support::children(&self.syntax)
7476 }
7477 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> {
7478 support::children(&self.syntax)
7479 }
7480 pub fn const_args(&self) -> AstChildren<ConstArg> {
7481 support::children(&self.syntax)
7482 }
7483 pub fn r_angle(&self) -> Option<RAngle> {
7484 support::token(&self.syntax)
7485 }
7486}
7487#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7488pub struct TypeArg {
7489 pub(crate) syntax: SyntaxNode,
7490}
7491impl std::fmt::Display for TypeArg {
7492 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7493 std::fmt::Display::fmt(self.syntax(), f)
7494 }
7495}
7496impl AstNode for TypeArg {
7497 fn can_cast(kind: SyntaxKind) -> bool {
7498 match kind {
7499 TYPE_ARG => true,
7500 _ => false,
7501 }
7502 }
7503 fn cast(syntax: SyntaxNode) -> Option<Self> {
7504 if Self::can_cast(syntax.kind()) {
7505 Some(Self { syntax })
7506 } else {
7507 None
7508 }
7509 }
7510 fn syntax(&self) -> &SyntaxNode {
7511 &self.syntax
7512 }
7513}
7514impl TypeArg {
7515 pub fn type_ref(&self) -> Option<TypeRef> {
7516 support::child(&self.syntax)
7517 }
7518}
7519#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7520pub struct AssocTypeArg {
7521 pub(crate) syntax: SyntaxNode,
7522}
7523impl std::fmt::Display for AssocTypeArg {
7524 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7525 std::fmt::Display::fmt(self.syntax(), f)
7526 }
7527}
7528impl AstNode for AssocTypeArg {
7529 fn can_cast(kind: SyntaxKind) -> bool {
7530 match kind {
7531 ASSOC_TYPE_ARG => true,
7532 _ => false,
7533 }
7534 }
7535 fn cast(syntax: SyntaxNode) -> Option<Self> {
7536 if Self::can_cast(syntax.kind()) {
7537 Some(Self { syntax })
7538 } else {
7539 None
7540 }
7541 }
7542 fn syntax(&self) -> &SyntaxNode {
7543 &self.syntax
7544 }
7545}
7546impl ast::TypeBoundsOwner for AssocTypeArg {}
7547impl AssocTypeArg {
7548 pub fn name_ref(&self) -> Option<NameRef> {
7549 support::child(&self.syntax)
7550 }
7551 pub fn eq(&self) -> Option<Eq> {
7552 support::token(&self.syntax)
7553 }
7554 pub fn type_ref(&self) -> Option<TypeRef> {
7555 support::child(&self.syntax)
7556 }
7557}
7558#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7559pub struct LifetimeArg {
7560 pub(crate) syntax: SyntaxNode,
7561}
7562impl std::fmt::Display for LifetimeArg {
7563 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7564 std::fmt::Display::fmt(self.syntax(), f)
7565 }
7566}
7567impl AstNode for LifetimeArg {
7568 fn can_cast(kind: SyntaxKind) -> bool {
7569 match kind {
7570 LIFETIME_ARG => true,
7571 _ => false,
7572 }
7573 }
7574 fn cast(syntax: SyntaxNode) -> Option<Self> {
7575 if Self::can_cast(syntax.kind()) {
7576 Some(Self { syntax })
7577 } else {
7578 None
7579 }
7580 }
7581 fn syntax(&self) -> &SyntaxNode {
7582 &self.syntax
7583 }
7584}
7585impl LifetimeArg {
7586 pub fn lifetime(&self) -> Option<Lifetime> {
7587 support::token(&self.syntax)
7588 }
7589}
7590#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7591pub struct ConstArg {
7592 pub(crate) syntax: SyntaxNode,
7593}
7594impl std::fmt::Display for ConstArg {
7595 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7596 std::fmt::Display::fmt(self.syntax(), f)
7597 }
7598}
7599impl AstNode for ConstArg {
7600 fn can_cast(kind: SyntaxKind) -> bool {
7601 match kind {
7602 CONST_ARG => true,
7603 _ => false,
7604 }
7605 }
7606 fn cast(syntax: SyntaxNode) -> Option<Self> {
7607 if Self::can_cast(syntax.kind()) {
7608 Some(Self { syntax })
7609 } else {
7610 None
7611 }
7612 }
7613 fn syntax(&self) -> &SyntaxNode {
7614 &self.syntax
7615 }
7616}
7617impl ConstArg {
7618 pub fn literal(&self) -> Option<Literal> {
7619 support::child(&self.syntax)
7620 }
7621 pub fn eq(&self) -> Option<Eq> {
7622 support::token(&self.syntax)
7623 }
7624 pub fn block_expr(&self) -> Option<BlockExpr> {
7625 support::child(&self.syntax)
7626 }
7627}
7628#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7629pub struct MacroItems {
7630 pub(crate) syntax: SyntaxNode,
7631}
7632impl std::fmt::Display for MacroItems {
7633 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7634 std::fmt::Display::fmt(self.syntax(), f)
7635 }
7636}
7637impl AstNode for MacroItems {
7638 fn can_cast(kind: SyntaxKind) -> bool {
7639 match kind {
7640 MACRO_ITEMS => true,
7641 _ => false,
7642 }
7643 }
7644 fn cast(syntax: SyntaxNode) -> Option<Self> {
7645 if Self::can_cast(syntax.kind()) {
7646 Some(Self { syntax })
7647 } else {
7648 None
7649 }
7650 }
7651 fn syntax(&self) -> &SyntaxNode {
7652 &self.syntax
7653 }
7654}
7655impl ast::ModuleItemOwner for MacroItems {}
7656impl ast::FnDefOwner for MacroItems {}
7657impl MacroItems {}
7658#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7659pub struct MacroStmts {
7660 pub(crate) syntax: SyntaxNode,
7661}
7662impl std::fmt::Display for MacroStmts {
7663 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7664 std::fmt::Display::fmt(self.syntax(), f)
7665 }
7666}
7667impl AstNode for MacroStmts {
7668 fn can_cast(kind: SyntaxKind) -> bool {
7669 match kind {
7670 MACRO_STMTS => true,
7671 _ => false,
7672 }
7673 }
7674 fn cast(syntax: SyntaxNode) -> Option<Self> {
7675 if Self::can_cast(syntax.kind()) {
7676 Some(Self { syntax })
7677 } else {
7678 None
7679 }
7680 }
7681 fn syntax(&self) -> &SyntaxNode {
7682 &self.syntax
7683 }
7684}
7685impl MacroStmts {
7686 pub fn statements(&self) -> AstChildren<Stmt> {
7687 support::children(&self.syntax)
7688 }
7689 pub fn expr(&self) -> Option<Expr> {
7690 support::child(&self.syntax)
7691 }
7692}
7693#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7694pub struct ExternItemList {
7695 pub(crate) syntax: SyntaxNode,
7696}
7697impl std::fmt::Display for ExternItemList {
7698 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7699 std::fmt::Display::fmt(self.syntax(), f)
7700 }
7701}
7702impl AstNode for ExternItemList {
7703 fn can_cast(kind: SyntaxKind) -> bool {
7704 match kind {
7705 EXTERN_ITEM_LIST => true,
7706 _ => false,
7707 }
7708 }
7709 fn cast(syntax: SyntaxNode) -> Option<Self> {
7710 if Self::can_cast(syntax.kind()) {
7711 Some(Self { syntax })
7712 } else {
7713 None
7714 }
7715 }
7716 fn syntax(&self) -> &SyntaxNode {
7717 &self.syntax
7718 }
7719}
7720impl ast::FnDefOwner for ExternItemList {}
7721impl ast::ModuleItemOwner for ExternItemList {}
7722impl ExternItemList {
7723 pub fn l_curly(&self) -> Option<LCurly> {
7724 support::token(&self.syntax)
7725 }
7726 pub fn extern_items(&self) -> AstChildren<ExternItem> {
7727 support::children(&self.syntax)
7728 }
7729 pub fn r_curly(&self) -> Option<RCurly> {
7730 support::token(&self.syntax)
7731 }
7732}
7733#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7734pub struct ExternBlock {
7735 pub(crate) syntax: SyntaxNode,
7736}
7737impl std::fmt::Display for ExternBlock {
7738 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7739 std::fmt::Display::fmt(self.syntax(), f)
7740 }
7741}
7742impl AstNode for ExternBlock {
7743 fn can_cast(kind: SyntaxKind) -> bool {
7744 match kind {
7745 EXTERN_BLOCK => true,
7746 _ => false,
7747 }
7748 }
7749 fn cast(syntax: SyntaxNode) -> Option<Self> {
7750 if Self::can_cast(syntax.kind()) {
7751 Some(Self { syntax })
7752 } else {
7753 None
7754 }
7755 }
7756 fn syntax(&self) -> &SyntaxNode {
7757 &self.syntax
7758 }
7759}
7760impl ExternBlock {
7761 pub fn abi(&self) -> Option<Abi> {
7762 support::child(&self.syntax)
7763 }
7764 pub fn extern_item_list(&self) -> Option<ExternItemList> {
7765 support::child(&self.syntax)
7766 }
7767}
7768#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7769pub struct MetaItem {
7770 pub(crate) syntax: SyntaxNode,
7771}
7772impl std::fmt::Display for MetaItem {
7773 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7774 std::fmt::Display::fmt(self.syntax(), f)
7775 }
7776}
7777impl AstNode for MetaItem {
7778 fn can_cast(kind: SyntaxKind) -> bool {
7779 match kind {
7780 META_ITEM => true,
7781 _ => false,
7782 }
7783 }
7784 fn cast(syntax: SyntaxNode) -> Option<Self> {
7785 if Self::can_cast(syntax.kind()) {
7786 Some(Self { syntax })
7787 } else {
7788 None
7789 }
7790 }
7791 fn syntax(&self) -> &SyntaxNode {
7792 &self.syntax
7793 }
7794}
7795impl MetaItem {
7796 pub fn path(&self) -> Option<Path> {
7797 support::child(&self.syntax)
7798 }
7799 pub fn eq(&self) -> Option<Eq> {
7800 support::token(&self.syntax)
7801 }
7802 pub fn attr_input(&self) -> Option<AttrInput> {
7803 support::child(&self.syntax)
7804 }
7805 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> {
7806 support::children(&self.syntax)
7807 }
7808}
7809#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7810pub struct MacroDef {
7811 pub(crate) syntax: SyntaxNode,
7812}
7813impl std::fmt::Display for MacroDef {
7814 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7815 std::fmt::Display::fmt(self.syntax(), f)
7816 }
7817}
7818impl AstNode for MacroDef {
7819 fn can_cast(kind: SyntaxKind) -> bool {
7820 match kind {
7821 MACRO_DEF => true,
7822 _ => false,
7823 }
7824 }
7825 fn cast(syntax: SyntaxNode) -> Option<Self> {
7826 if Self::can_cast(syntax.kind()) {
7827 Some(Self { syntax })
7828 } else {
7829 None
7830 }
7831 }
7832 fn syntax(&self) -> &SyntaxNode {
7833 &self.syntax
7834 }
7835}
7836impl MacroDef {
7837 pub fn name(&self) -> Option<Name> {
7838 support::child(&self.syntax)
7839 }
7840 pub fn token_tree(&self) -> Option<TokenTree> {
7841 support::child(&self.syntax)
7842 }
7843}
7844#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7845pub enum NominalDef {
7846 StructDef(StructDef),
7847 EnumDef(EnumDef),
7848 UnionDef(UnionDef),
7849}
7850impl From<StructDef> for NominalDef {
7851 fn from(node: StructDef) -> NominalDef {
7852 NominalDef::StructDef(node)
7853 }
7854}
7855impl From<EnumDef> for NominalDef {
7856 fn from(node: EnumDef) -> NominalDef {
7857 NominalDef::EnumDef(node)
7858 }
7859}
7860impl From<UnionDef> for NominalDef {
7861 fn from(node: UnionDef) -> NominalDef {
7862 NominalDef::UnionDef(node)
7863 }
7864}
7865impl std::fmt::Display for NominalDef {
7866 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7867 std::fmt::Display::fmt(self.syntax(), f)
7868 }
7869}
7870impl AstNode for NominalDef {
7871 fn can_cast(kind: SyntaxKind) -> bool {
7872 match kind {
7873 STRUCT_DEF | ENUM_DEF | UNION_DEF => true,
7874 _ => false,
7875 }
7876 }
7877 fn cast(syntax: SyntaxNode) -> Option<Self> {
7878 let res = match syntax.kind() {
7879 STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
7880 ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
7881 UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }),
7882 _ => return None,
7883 };
7884 Some(res)
7885 }
7886 fn syntax(&self) -> &SyntaxNode {
7887 match self {
7888 NominalDef::StructDef(it) => &it.syntax,
7889 NominalDef::EnumDef(it) => &it.syntax,
7890 NominalDef::UnionDef(it) => &it.syntax,
7891 }
7892 }
7893}
7894impl ast::NameOwner for NominalDef {}
7895impl ast::TypeParamsOwner for NominalDef {}
7896impl ast::AttrsOwner for NominalDef {}
7897#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7898pub enum GenericParam {
7899 LifetimeParam(LifetimeParam),
7900 TypeParam(TypeParam),
7901 ConstParam(ConstParam),
7902}
7903impl From<LifetimeParam> for GenericParam {
7904 fn from(node: LifetimeParam) -> GenericParam {
7905 GenericParam::LifetimeParam(node)
7906 }
7907}
7908impl From<TypeParam> for GenericParam {
7909 fn from(node: TypeParam) -> GenericParam {
7910 GenericParam::TypeParam(node)
7911 }
7912}
7913impl From<ConstParam> for GenericParam {
7914 fn from(node: ConstParam) -> GenericParam {
7915 GenericParam::ConstParam(node)
7916 }
7917}
7918impl std::fmt::Display for GenericParam {
7919 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7920 std::fmt::Display::fmt(self.syntax(), f)
7921 }
7922}
7923impl AstNode for GenericParam {
7924 fn can_cast(kind: SyntaxKind) -> bool {
7925 match kind {
7926 LIFETIME_PARAM | TYPE_PARAM | CONST_PARAM => true,
7927 _ => false,
7928 }
7929 }
7930 fn cast(syntax: SyntaxNode) -> Option<Self> {
7931 let res = match syntax.kind() {
7932 LIFETIME_PARAM => GenericParam::LifetimeParam(LifetimeParam { syntax }),
7933 TYPE_PARAM => GenericParam::TypeParam(TypeParam { syntax }),
7934 CONST_PARAM => GenericParam::ConstParam(ConstParam { syntax }),
7935 _ => return None,
7936 };
7937 Some(res)
7938 }
7939 fn syntax(&self) -> &SyntaxNode {
7940 match self {
7941 GenericParam::LifetimeParam(it) => &it.syntax,
7942 GenericParam::TypeParam(it) => &it.syntax,
7943 GenericParam::ConstParam(it) => &it.syntax,
7944 }
7945 }
7946}
7947#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7948pub enum GenericArg {
7949 LifetimeArg(LifetimeArg),
7950 TypeArg(TypeArg),
7951 ConstArg(ConstArg),
7952 AssocTypeArg(AssocTypeArg),
7953}
7954impl From<LifetimeArg> for GenericArg {
7955 fn from(node: LifetimeArg) -> GenericArg {
7956 GenericArg::LifetimeArg(node)
7957 }
7958}
7959impl From<TypeArg> for GenericArg {
7960 fn from(node: TypeArg) -> GenericArg {
7961 GenericArg::TypeArg(node)
7962 }
7963}
7964impl From<ConstArg> for GenericArg {
7965 fn from(node: ConstArg) -> GenericArg {
7966 GenericArg::ConstArg(node)
7967 }
7968}
7969impl From<AssocTypeArg> for GenericArg {
7970 fn from(node: AssocTypeArg) -> GenericArg {
7971 GenericArg::AssocTypeArg(node)
7972 }
7973}
7974impl std::fmt::Display for GenericArg {
7975 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7976 std::fmt::Display::fmt(self.syntax(), f)
7977 }
7978}
7979impl AstNode for GenericArg {
7980 fn can_cast(kind: SyntaxKind) -> bool {
7981 match kind {
7982 LIFETIME_ARG | TYPE_ARG | CONST_ARG | ASSOC_TYPE_ARG => true,
7983 _ => false,
7984 }
7985 }
7986 fn cast(syntax: SyntaxNode) -> Option<Self> {
7987 let res = match syntax.kind() {
7988 LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }),
7989 TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }),
7990 CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }),
7991 ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }),
7992 _ => return None,
7993 };
7994 Some(res)
7995 }
7996 fn syntax(&self) -> &SyntaxNode {
7997 match self {
7998 GenericArg::LifetimeArg(it) => &it.syntax,
7999 GenericArg::TypeArg(it) => &it.syntax,
8000 GenericArg::ConstArg(it) => &it.syntax,
8001 GenericArg::AssocTypeArg(it) => &it.syntax,
8002 }
8003 }
8004}
8005#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8006pub enum TypeRef {
8007 ParenType(ParenType),
8008 TupleType(TupleType),
8009 NeverType(NeverType),
8010 PathType(PathType),
8011 PointerType(PointerType),
8012 ArrayType(ArrayType),
8013 SliceType(SliceType),
8014 ReferenceType(ReferenceType),
8015 PlaceholderType(PlaceholderType),
8016 FnPointerType(FnPointerType),
8017 ForType(ForType),
8018 ImplTraitType(ImplTraitType),
8019 DynTraitType(DynTraitType),
8020}
8021impl From<ParenType> for TypeRef {
8022 fn from(node: ParenType) -> TypeRef {
8023 TypeRef::ParenType(node)
8024 }
8025}
8026impl From<TupleType> for TypeRef {
8027 fn from(node: TupleType) -> TypeRef {
8028 TypeRef::TupleType(node)
8029 }
8030}
8031impl From<NeverType> for TypeRef {
8032 fn from(node: NeverType) -> TypeRef {
8033 TypeRef::NeverType(node)
8034 }
8035}
8036impl From<PathType> for TypeRef {
8037 fn from(node: PathType) -> TypeRef {
8038 TypeRef::PathType(node)
8039 }
8040}
8041impl From<PointerType> for TypeRef {
8042 fn from(node: PointerType) -> TypeRef {
8043 TypeRef::PointerType(node)
8044 }
8045}
8046impl From<ArrayType> for TypeRef {
8047 fn from(node: ArrayType) -> TypeRef {
8048 TypeRef::ArrayType(node)
8049 }
8050}
8051impl From<SliceType> for TypeRef {
8052 fn from(node: SliceType) -> TypeRef {
8053 TypeRef::SliceType(node)
8054 }
8055}
8056impl From<ReferenceType> for TypeRef {
8057 fn from(node: ReferenceType) -> TypeRef {
8058 TypeRef::ReferenceType(node)
8059 }
8060}
8061impl From<PlaceholderType> for TypeRef {
8062 fn from(node: PlaceholderType) -> TypeRef {
8063 TypeRef::PlaceholderType(node)
8064 }
8065}
8066impl From<FnPointerType> for TypeRef {
8067 fn from(node: FnPointerType) -> TypeRef {
8068 TypeRef::FnPointerType(node)
8069 }
8070}
8071impl From<ForType> for TypeRef {
8072 fn from(node: ForType) -> TypeRef {
8073 TypeRef::ForType(node)
8074 }
8075}
8076impl From<ImplTraitType> for TypeRef {
8077 fn from(node: ImplTraitType) -> TypeRef {
8078 TypeRef::ImplTraitType(node)
8079 }
8080}
8081impl From<DynTraitType> for TypeRef {
8082 fn from(node: DynTraitType) -> TypeRef {
8083 TypeRef::DynTraitType(node)
8084 }
8085}
8086impl std::fmt::Display for TypeRef {
8087 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8088 std::fmt::Display::fmt(self.syntax(), f)
8089 }
8090}
8091impl AstNode for TypeRef {
8092 fn can_cast(kind: SyntaxKind) -> bool {
8093 match kind {
8094 PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
8095 | SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
8096 | IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
8097 _ => false,
8098 }
8099 }
8100 fn cast(syntax: SyntaxNode) -> Option<Self> {
8101 let res = match syntax.kind() {
8102 PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }),
8103 TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }),
8104 NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }),
8105 PATH_TYPE => TypeRef::PathType(PathType { syntax }),
8106 POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }),
8107 ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }),
8108 SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }),
8109 REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }),
8110 PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }),
8111 FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }),
8112 FOR_TYPE => TypeRef::ForType(ForType { syntax }),
8113 IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }),
8114 DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }),
8115 _ => return None,
8116 };
8117 Some(res)
8118 }
8119 fn syntax(&self) -> &SyntaxNode {
8120 match self {
8121 TypeRef::ParenType(it) => &it.syntax,
8122 TypeRef::TupleType(it) => &it.syntax,
8123 TypeRef::NeverType(it) => &it.syntax,
8124 TypeRef::PathType(it) => &it.syntax,
8125 TypeRef::PointerType(it) => &it.syntax,
8126 TypeRef::ArrayType(it) => &it.syntax,
8127 TypeRef::SliceType(it) => &it.syntax,
8128 TypeRef::ReferenceType(it) => &it.syntax,
8129 TypeRef::PlaceholderType(it) => &it.syntax,
8130 TypeRef::FnPointerType(it) => &it.syntax,
8131 TypeRef::ForType(it) => &it.syntax,
8132 TypeRef::ImplTraitType(it) => &it.syntax,
8133 TypeRef::DynTraitType(it) => &it.syntax,
8134 }
8135 }
8136}
8137#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8138pub enum ModuleItem {
8139 StructDef(StructDef),
8140 UnionDef(UnionDef),
8141 EnumDef(EnumDef),
8142 FnDef(FnDef),
8143 TraitDef(TraitDef),
8144 TypeAliasDef(TypeAliasDef),
8145 ImplDef(ImplDef),
8146 UseItem(UseItem),
8147 ExternCrateItem(ExternCrateItem),
8148 ConstDef(ConstDef),
8149 StaticDef(StaticDef),
8150 Module(Module),
8151 MacroCall(MacroCall),
8152 ExternBlock(ExternBlock),
8153}
8154impl From<StructDef> for ModuleItem {
8155 fn from(node: StructDef) -> ModuleItem {
8156 ModuleItem::StructDef(node)
8157 }
8158}
8159impl From<UnionDef> for ModuleItem {
8160 fn from(node: UnionDef) -> ModuleItem {
8161 ModuleItem::UnionDef(node)
8162 }
8163}
8164impl From<EnumDef> for ModuleItem {
8165 fn from(node: EnumDef) -> ModuleItem {
8166 ModuleItem::EnumDef(node)
8167 }
8168}
8169impl From<FnDef> for ModuleItem {
8170 fn from(node: FnDef) -> ModuleItem {
8171 ModuleItem::FnDef(node)
8172 }
8173}
8174impl From<TraitDef> for ModuleItem {
8175 fn from(node: TraitDef) -> ModuleItem {
8176 ModuleItem::TraitDef(node)
8177 }
8178}
8179impl From<TypeAliasDef> for ModuleItem {
8180 fn from(node: TypeAliasDef) -> ModuleItem {
8181 ModuleItem::TypeAliasDef(node)
8182 }
8183}
8184impl From<ImplDef> for ModuleItem {
8185 fn from(node: ImplDef) -> ModuleItem {
8186 ModuleItem::ImplDef(node)
8187 }
8188}
8189impl From<UseItem> for ModuleItem {
8190 fn from(node: UseItem) -> ModuleItem {
8191 ModuleItem::UseItem(node)
8192 }
8193}
8194impl From<ExternCrateItem> for ModuleItem {
8195 fn from(node: ExternCrateItem) -> ModuleItem {
8196 ModuleItem::ExternCrateItem(node)
8197 }
8198}
8199impl From<ConstDef> for ModuleItem {
8200 fn from(node: ConstDef) -> ModuleItem {
8201 ModuleItem::ConstDef(node)
8202 }
8203}
8204impl From<StaticDef> for ModuleItem {
8205 fn from(node: StaticDef) -> ModuleItem {
8206 ModuleItem::StaticDef(node)
8207 }
8208}
8209impl From<Module> for ModuleItem {
8210 fn from(node: Module) -> ModuleItem {
8211 ModuleItem::Module(node)
8212 }
8213}
8214impl From<MacroCall> for ModuleItem {
8215 fn from(node: MacroCall) -> ModuleItem {
8216 ModuleItem::MacroCall(node)
8217 }
8218}
8219impl From<ExternBlock> for ModuleItem {
8220 fn from(node: ExternBlock) -> ModuleItem {
8221 ModuleItem::ExternBlock(node)
8222 }
8223}
8224impl std::fmt::Display for ModuleItem {
8225 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8226 std::fmt::Display::fmt(self.syntax(), f)
8227 }
8228}
8229impl AstNode for ModuleItem {
8230 fn can_cast(kind: SyntaxKind) -> bool {
8231 match kind {
8232 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF
8233 | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL
8234 | EXTERN_BLOCK => true,
8235 _ => false,
8236 }
8237 }
8238 fn cast(syntax: SyntaxNode) -> Option<Self> {
8239 let res = match syntax.kind() {
8240 STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
8241 UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }),
8242 ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
8243 FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
8244 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
8245 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
8246 IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }),
8247 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
8248 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
8249 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
8250 STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
8251 MODULE => ModuleItem::Module(Module { syntax }),
8252 MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }),
8253 EXTERN_BLOCK => ModuleItem::ExternBlock(ExternBlock { syntax }),
8254 _ => return None,
8255 };
8256 Some(res)
8257 }
8258 fn syntax(&self) -> &SyntaxNode {
8259 match self {
8260 ModuleItem::StructDef(it) => &it.syntax,
8261 ModuleItem::UnionDef(it) => &it.syntax,
8262 ModuleItem::EnumDef(it) => &it.syntax,
8263 ModuleItem::FnDef(it) => &it.syntax,
8264 ModuleItem::TraitDef(it) => &it.syntax,
8265 ModuleItem::TypeAliasDef(it) => &it.syntax,
8266 ModuleItem::ImplDef(it) => &it.syntax,
8267 ModuleItem::UseItem(it) => &it.syntax,
8268 ModuleItem::ExternCrateItem(it) => &it.syntax,
8269 ModuleItem::ConstDef(it) => &it.syntax,
8270 ModuleItem::StaticDef(it) => &it.syntax,
8271 ModuleItem::Module(it) => &it.syntax,
8272 ModuleItem::MacroCall(it) => &it.syntax,
8273 ModuleItem::ExternBlock(it) => &it.syntax,
8274 }
8275 }
8276}
8277impl ast::NameOwner for ModuleItem {}
8278impl ast::AttrsOwner for ModuleItem {}
8279impl ast::VisibilityOwner for ModuleItem {}
8280#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8281pub enum ImplItem {
8282 FnDef(FnDef),
8283 TypeAliasDef(TypeAliasDef),
8284 ConstDef(ConstDef),
8285}
8286impl From<FnDef> for ImplItem {
8287 fn from(node: FnDef) -> ImplItem {
8288 ImplItem::FnDef(node)
8289 }
8290}
8291impl From<TypeAliasDef> for ImplItem {
8292 fn from(node: TypeAliasDef) -> ImplItem {
8293 ImplItem::TypeAliasDef(node)
8294 }
8295}
8296impl From<ConstDef> for ImplItem {
8297 fn from(node: ConstDef) -> ImplItem {
8298 ImplItem::ConstDef(node)
8299 }
8300}
8301impl std::fmt::Display for ImplItem {
8302 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8303 std::fmt::Display::fmt(self.syntax(), f)
8304 }
8305}
8306impl AstNode for ImplItem {
8307 fn can_cast(kind: SyntaxKind) -> bool {
8308 match kind {
8309 FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true,
8310 _ => false,
8311 }
8312 }
8313 fn cast(syntax: SyntaxNode) -> Option<Self> {
8314 let res = match syntax.kind() {
8315 FN_DEF => ImplItem::FnDef(FnDef { syntax }),
8316 TYPE_ALIAS_DEF => ImplItem::TypeAliasDef(TypeAliasDef { syntax }),
8317 CONST_DEF => ImplItem::ConstDef(ConstDef { syntax }),
8318 _ => return None,
8319 };
8320 Some(res)
8321 }
8322 fn syntax(&self) -> &SyntaxNode {
8323 match self {
8324 ImplItem::FnDef(it) => &it.syntax,
8325 ImplItem::TypeAliasDef(it) => &it.syntax,
8326 ImplItem::ConstDef(it) => &it.syntax,
8327 }
8328 }
8329}
8330impl ast::NameOwner for ImplItem {}
8331impl ast::AttrsOwner for ImplItem {}
8332#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8333pub enum ExternItem {
8334 FnDef(FnDef),
8335 StaticDef(StaticDef),
8336}
8337impl From<FnDef> for ExternItem {
8338 fn from(node: FnDef) -> ExternItem {
8339 ExternItem::FnDef(node)
8340 }
8341}
8342impl From<StaticDef> for ExternItem {
8343 fn from(node: StaticDef) -> ExternItem {
8344 ExternItem::StaticDef(node)
8345 }
8346}
8347impl std::fmt::Display for ExternItem {
8348 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8349 std::fmt::Display::fmt(self.syntax(), f)
8350 }
8351}
8352impl AstNode for ExternItem {
8353 fn can_cast(kind: SyntaxKind) -> bool {
8354 match kind {
8355 FN_DEF | STATIC_DEF => true,
8356 _ => false,
8357 }
8358 }
8359 fn cast(syntax: SyntaxNode) -> Option<Self> {
8360 let res = match syntax.kind() {
8361 FN_DEF => ExternItem::FnDef(FnDef { syntax }),
8362 STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }),
8363 _ => return None,
8364 };
8365 Some(res)
8366 }
8367 fn syntax(&self) -> &SyntaxNode {
8368 match self {
8369 ExternItem::FnDef(it) => &it.syntax,
8370 ExternItem::StaticDef(it) => &it.syntax,
8371 }
8372 }
8373}
8374impl ast::NameOwner for ExternItem {}
8375impl ast::AttrsOwner for ExternItem {}
8376impl ast::VisibilityOwner for ExternItem {}
8377#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8378pub enum Expr {
8379 TupleExpr(TupleExpr),
8380 ArrayExpr(ArrayExpr),
8381 ParenExpr(ParenExpr),
8382 PathExpr(PathExpr),
8383 LambdaExpr(LambdaExpr),
8384 IfExpr(IfExpr),
8385 LoopExpr(LoopExpr),
8386 ForExpr(ForExpr),
8387 WhileExpr(WhileExpr),
8388 ContinueExpr(ContinueExpr),
8389 BreakExpr(BreakExpr),
8390 Label(Label),
8391 BlockExpr(BlockExpr),
8392 ReturnExpr(ReturnExpr),
8393 MatchExpr(MatchExpr),
8394 RecordLit(RecordLit),
8395 CallExpr(CallExpr),
8396 IndexExpr(IndexExpr),
8397 MethodCallExpr(MethodCallExpr),
8398 FieldExpr(FieldExpr),
8399 AwaitExpr(AwaitExpr),
8400 TryExpr(TryExpr),
8401 TryBlockExpr(TryBlockExpr),
8402 CastExpr(CastExpr),
8403 RefExpr(RefExpr),
8404 PrefixExpr(PrefixExpr),
8405 RangeExpr(RangeExpr),
8406 BinExpr(BinExpr),
8407 Literal(Literal),
8408 MacroCall(MacroCall),
8409 BoxExpr(BoxExpr),
8410}
8411impl From<TupleExpr> for Expr {
8412 fn from(node: TupleExpr) -> Expr {
8413 Expr::TupleExpr(node)
8414 }
8415}
8416impl From<ArrayExpr> for Expr {
8417 fn from(node: ArrayExpr) -> Expr {
8418 Expr::ArrayExpr(node)
8419 }
8420}
8421impl From<ParenExpr> for Expr {
8422 fn from(node: ParenExpr) -> Expr {
8423 Expr::ParenExpr(node)
8424 }
8425}
8426impl From<PathExpr> for Expr {
8427 fn from(node: PathExpr) -> Expr {
8428 Expr::PathExpr(node)
8429 }
8430}
8431impl From<LambdaExpr> for Expr {
8432 fn from(node: LambdaExpr) -> Expr {
8433 Expr::LambdaExpr(node)
8434 }
8435}
8436impl From<IfExpr> for Expr {
8437 fn from(node: IfExpr) -> Expr {
8438 Expr::IfExpr(node)
8439 }
8440}
8441impl From<LoopExpr> for Expr {
8442 fn from(node: LoopExpr) -> Expr {
8443 Expr::LoopExpr(node)
8444 }
8445}
8446impl From<ForExpr> for Expr {
8447 fn from(node: ForExpr) -> Expr {
8448 Expr::ForExpr(node)
8449 }
8450}
8451impl From<WhileExpr> for Expr {
8452 fn from(node: WhileExpr) -> Expr {
8453 Expr::WhileExpr(node)
8454 }
8455}
8456impl From<ContinueExpr> for Expr {
8457 fn from(node: ContinueExpr) -> Expr {
8458 Expr::ContinueExpr(node)
8459 }
8460}
8461impl From<BreakExpr> for Expr {
8462 fn from(node: BreakExpr) -> Expr {
8463 Expr::BreakExpr(node)
8464 }
8465}
8466impl From<Label> for Expr {
8467 fn from(node: Label) -> Expr {
8468 Expr::Label(node)
8469 }
8470}
8471impl From<BlockExpr> for Expr {
8472 fn from(node: BlockExpr) -> Expr {
8473 Expr::BlockExpr(node)
8474 }
8475}
8476impl From<ReturnExpr> for Expr {
8477 fn from(node: ReturnExpr) -> Expr {
8478 Expr::ReturnExpr(node)
8479 }
8480}
8481impl From<MatchExpr> for Expr {
8482 fn from(node: MatchExpr) -> Expr {
8483 Expr::MatchExpr(node)
8484 }
8485}
8486impl From<RecordLit> for Expr {
8487 fn from(node: RecordLit) -> Expr {
8488 Expr::RecordLit(node)
8489 }
8490}
8491impl From<CallExpr> for Expr {
8492 fn from(node: CallExpr) -> Expr {
8493 Expr::CallExpr(node)
8494 }
8495}
8496impl From<IndexExpr> for Expr {
8497 fn from(node: IndexExpr) -> Expr {
8498 Expr::IndexExpr(node)
8499 }
8500}
8501impl From<MethodCallExpr> for Expr {
8502 fn from(node: MethodCallExpr) -> Expr {
8503 Expr::MethodCallExpr(node)
8504 }
8505}
8506impl From<FieldExpr> for Expr {
8507 fn from(node: FieldExpr) -> Expr {
8508 Expr::FieldExpr(node)
8509 }
8510}
8511impl From<AwaitExpr> for Expr {
8512 fn from(node: AwaitExpr) -> Expr {
8513 Expr::AwaitExpr(node)
8514 }
8515}
8516impl From<TryExpr> for Expr {
8517 fn from(node: TryExpr) -> Expr {
8518 Expr::TryExpr(node)
8519 }
8520}
8521impl From<TryBlockExpr> for Expr {
8522 fn from(node: TryBlockExpr) -> Expr {
8523 Expr::TryBlockExpr(node)
8524 }
8525}
8526impl From<CastExpr> for Expr {
8527 fn from(node: CastExpr) -> Expr {
8528 Expr::CastExpr(node)
8529 }
8530}
8531impl From<RefExpr> for Expr {
8532 fn from(node: RefExpr) -> Expr {
8533 Expr::RefExpr(node)
8534 }
8535}
8536impl From<PrefixExpr> for Expr {
8537 fn from(node: PrefixExpr) -> Expr {
8538 Expr::PrefixExpr(node)
8539 }
8540}
8541impl From<RangeExpr> for Expr {
8542 fn from(node: RangeExpr) -> Expr {
8543 Expr::RangeExpr(node)
8544 }
8545}
8546impl From<BinExpr> for Expr {
8547 fn from(node: BinExpr) -> Expr {
8548 Expr::BinExpr(node)
8549 }
8550}
8551impl From<Literal> for Expr {
8552 fn from(node: Literal) -> Expr {
8553 Expr::Literal(node)
8554 }
8555}
8556impl From<MacroCall> for Expr {
8557 fn from(node: MacroCall) -> Expr {
8558 Expr::MacroCall(node)
8559 }
8560}
8561impl From<BoxExpr> for Expr {
8562 fn from(node: BoxExpr) -> Expr {
8563 Expr::BoxExpr(node)
8564 }
8565}
8566impl std::fmt::Display for Expr {
8567 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8568 std::fmt::Display::fmt(self.syntax(), f)
8569 }
8570}
8571impl AstNode for Expr {
8572 fn can_cast(kind: SyntaxKind) -> bool {
8573 match kind {
8574 TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
8575 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
8576 | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR
8577 | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR
8578 | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL
8579 | BOX_EXPR => true,
8580 _ => false,
8581 }
8582 }
8583 fn cast(syntax: SyntaxNode) -> Option<Self> {
8584 let res = match syntax.kind() {
8585 TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }),
8586 ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }),
8587 PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }),
8588 PATH_EXPR => Expr::PathExpr(PathExpr { syntax }),
8589 LAMBDA_EXPR => Expr::LambdaExpr(LambdaExpr { syntax }),
8590 IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
8591 LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }),
8592 FOR_EXPR => Expr::ForExpr(ForExpr { syntax }),
8593 WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }),
8594 CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }),
8595 BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }),
8596 LABEL => Expr::Label(Label { syntax }),
8597 BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
8598 RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
8599 MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
8600 RECORD_LIT => Expr::RecordLit(RecordLit { syntax }),
8601 CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
8602 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
8603 METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
8604 FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }),
8605 AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }),
8606 TRY_EXPR => Expr::TryExpr(TryExpr { syntax }),
8607 TRY_BLOCK_EXPR => Expr::TryBlockExpr(TryBlockExpr { syntax }),
8608 CAST_EXPR => Expr::CastExpr(CastExpr { syntax }),
8609 REF_EXPR => Expr::RefExpr(RefExpr { syntax }),
8610 PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }),
8611 RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }),
8612 BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
8613 LITERAL => Expr::Literal(Literal { syntax }),
8614 MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
8615 BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }),
8616 _ => return None,
8617 };
8618 Some(res)
8619 }
8620 fn syntax(&self) -> &SyntaxNode {
8621 match self {
8622 Expr::TupleExpr(it) => &it.syntax,
8623 Expr::ArrayExpr(it) => &it.syntax,
8624 Expr::ParenExpr(it) => &it.syntax,
8625 Expr::PathExpr(it) => &it.syntax,
8626 Expr::LambdaExpr(it) => &it.syntax,
8627 Expr::IfExpr(it) => &it.syntax,
8628 Expr::LoopExpr(it) => &it.syntax,
8629 Expr::ForExpr(it) => &it.syntax,
8630 Expr::WhileExpr(it) => &it.syntax,
8631 Expr::ContinueExpr(it) => &it.syntax,
8632 Expr::BreakExpr(it) => &it.syntax,
8633 Expr::Label(it) => &it.syntax,
8634 Expr::BlockExpr(it) => &it.syntax,
8635 Expr::ReturnExpr(it) => &it.syntax,
8636 Expr::MatchExpr(it) => &it.syntax,
8637 Expr::RecordLit(it) => &it.syntax,
8638 Expr::CallExpr(it) => &it.syntax,
8639 Expr::IndexExpr(it) => &it.syntax,
8640 Expr::MethodCallExpr(it) => &it.syntax,
8641 Expr::FieldExpr(it) => &it.syntax,
8642 Expr::AwaitExpr(it) => &it.syntax,
8643 Expr::TryExpr(it) => &it.syntax,
8644 Expr::TryBlockExpr(it) => &it.syntax,
8645 Expr::CastExpr(it) => &it.syntax,
8646 Expr::RefExpr(it) => &it.syntax,
8647 Expr::PrefixExpr(it) => &it.syntax,
8648 Expr::RangeExpr(it) => &it.syntax,
8649 Expr::BinExpr(it) => &it.syntax,
8650 Expr::Literal(it) => &it.syntax,
8651 Expr::MacroCall(it) => &it.syntax,
8652 Expr::BoxExpr(it) => &it.syntax,
8653 }
8654 }
8655}
8656impl ast::AttrsOwner for Expr {}
8657#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8658pub enum Pat {
8659 OrPat(OrPat),
8660 ParenPat(ParenPat),
8661 RefPat(RefPat),
8662 BoxPat(BoxPat),
8663 BindPat(BindPat),
8664 PlaceholderPat(PlaceholderPat),
8665 DotDotPat(DotDotPat),
8666 PathPat(PathPat),
8667 RecordPat(RecordPat),
8668 TupleStructPat(TupleStructPat),
8669 TuplePat(TuplePat),
8670 SlicePat(SlicePat),
8671 RangePat(RangePat),
8672 LiteralPat(LiteralPat),
8673 MacroPat(MacroPat),
8674}
8675impl From<OrPat> for Pat {
8676 fn from(node: OrPat) -> Pat {
8677 Pat::OrPat(node)
8678 }
8679}
8680impl From<ParenPat> for Pat {
8681 fn from(node: ParenPat) -> Pat {
8682 Pat::ParenPat(node)
8683 }
8684}
8685impl From<RefPat> for Pat {
8686 fn from(node: RefPat) -> Pat {
8687 Pat::RefPat(node)
8688 }
8689}
8690impl From<BoxPat> for Pat {
8691 fn from(node: BoxPat) -> Pat {
8692 Pat::BoxPat(node)
8693 }
8694}
8695impl From<BindPat> for Pat {
8696 fn from(node: BindPat) -> Pat {
8697 Pat::BindPat(node)
8698 }
8699}
8700impl From<PlaceholderPat> for Pat {
8701 fn from(node: PlaceholderPat) -> Pat {
8702 Pat::PlaceholderPat(node)
8703 }
8704}
8705impl From<DotDotPat> for Pat {
8706 fn from(node: DotDotPat) -> Pat {
8707 Pat::DotDotPat(node)
8708 }
8709}
8710impl From<PathPat> for Pat {
8711 fn from(node: PathPat) -> Pat {
8712 Pat::PathPat(node)
8713 }
8714}
8715impl From<RecordPat> for Pat {
8716 fn from(node: RecordPat) -> Pat {
8717 Pat::RecordPat(node)
8718 }
8719}
8720impl From<TupleStructPat> for Pat {
8721 fn from(node: TupleStructPat) -> Pat {
8722 Pat::TupleStructPat(node)
8723 }
8724}
8725impl From<TuplePat> for Pat {
8726 fn from(node: TuplePat) -> Pat {
8727 Pat::TuplePat(node)
8728 }
8729}
8730impl From<SlicePat> for Pat {
8731 fn from(node: SlicePat) -> Pat {
8732 Pat::SlicePat(node)
8733 }
8734}
8735impl From<RangePat> for Pat {
8736 fn from(node: RangePat) -> Pat {
8737 Pat::RangePat(node)
8738 }
8739}
8740impl From<LiteralPat> for Pat {
8741 fn from(node: LiteralPat) -> Pat {
8742 Pat::LiteralPat(node)
8743 }
8744}
8745impl From<MacroPat> for Pat {
8746 fn from(node: MacroPat) -> Pat {
8747 Pat::MacroPat(node)
8748 }
8749}
8750impl std::fmt::Display for Pat {
8751 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8752 std::fmt::Display::fmt(self.syntax(), f)
8753 }
8754}
8755impl AstNode for Pat {
8756 fn can_cast(kind: SyntaxKind) -> bool {
8757 match kind {
8758 OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT
8759 | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT
8760 | LITERAL_PAT | MACRO_PAT => true,
8761 _ => false,
8762 }
8763 }
8764 fn cast(syntax: SyntaxNode) -> Option<Self> {
8765 let res = match syntax.kind() {
8766 OR_PAT => Pat::OrPat(OrPat { syntax }),
8767 PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
8768 REF_PAT => Pat::RefPat(RefPat { syntax }),
8769 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
8770 BIND_PAT => Pat::BindPat(BindPat { syntax }),
8771 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
8772 DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
8773 PATH_PAT => Pat::PathPat(PathPat { syntax }),
8774 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
8775 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
8776 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
8777 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
8778 RANGE_PAT => Pat::RangePat(RangePat { syntax }),
8779 LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
8780 MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
8781 _ => return None,
8782 };
8783 Some(res)
8784 }
8785 fn syntax(&self) -> &SyntaxNode {
8786 match self {
8787 Pat::OrPat(it) => &it.syntax,
8788 Pat::ParenPat(it) => &it.syntax,
8789 Pat::RefPat(it) => &it.syntax,
8790 Pat::BoxPat(it) => &it.syntax,
8791 Pat::BindPat(it) => &it.syntax,
8792 Pat::PlaceholderPat(it) => &it.syntax,
8793 Pat::DotDotPat(it) => &it.syntax,
8794 Pat::PathPat(it) => &it.syntax,
8795 Pat::RecordPat(it) => &it.syntax,
8796 Pat::TupleStructPat(it) => &it.syntax,
8797 Pat::TuplePat(it) => &it.syntax,
8798 Pat::SlicePat(it) => &it.syntax,
8799 Pat::RangePat(it) => &it.syntax,
8800 Pat::LiteralPat(it) => &it.syntax,
8801 Pat::MacroPat(it) => &it.syntax,
8802 }
8803 }
8804}
8805#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8806pub enum RecordInnerPat {
8807 RecordFieldPat(RecordFieldPat),
8808 BindPat(BindPat),
8809}
8810impl From<RecordFieldPat> for RecordInnerPat {
8811 fn from(node: RecordFieldPat) -> RecordInnerPat {
8812 RecordInnerPat::RecordFieldPat(node)
8813 }
8814}
8815impl From<BindPat> for RecordInnerPat {
8816 fn from(node: BindPat) -> RecordInnerPat {
8817 RecordInnerPat::BindPat(node)
8818 }
8819}
8820impl std::fmt::Display for RecordInnerPat {
8821 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8822 std::fmt::Display::fmt(self.syntax(), f)
8823 }
8824}
8825impl AstNode for RecordInnerPat {
8826 fn can_cast(kind: SyntaxKind) -> bool {
8827 match kind {
8828 RECORD_FIELD_PAT | BIND_PAT => true,
8829 _ => false,
8830 }
8831 }
8832 fn cast(syntax: SyntaxNode) -> Option<Self> {
8833 let res = match syntax.kind() {
8834 RECORD_FIELD_PAT => RecordInnerPat::RecordFieldPat(RecordFieldPat { syntax }),
8835 BIND_PAT => RecordInnerPat::BindPat(BindPat { syntax }),
8836 _ => return None,
8837 };
8838 Some(res)
8839 }
8840 fn syntax(&self) -> &SyntaxNode {
8841 match self {
8842 RecordInnerPat::RecordFieldPat(it) => &it.syntax,
8843 RecordInnerPat::BindPat(it) => &it.syntax,
8844 }
8845 }
8846}
8847#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8848pub enum AttrInput {
8849 Literal(Literal),
8850 TokenTree(TokenTree),
8851}
8852impl From<Literal> for AttrInput {
8853 fn from(node: Literal) -> AttrInput {
8854 AttrInput::Literal(node)
8855 }
8856}
8857impl From<TokenTree> for AttrInput {
8858 fn from(node: TokenTree) -> AttrInput {
8859 AttrInput::TokenTree(node)
8860 }
8861}
8862impl std::fmt::Display for AttrInput {
8863 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8864 std::fmt::Display::fmt(self.syntax(), f)
8865 }
8866}
8867impl AstNode for AttrInput {
8868 fn can_cast(kind: SyntaxKind) -> bool {
8869 match kind {
8870 LITERAL | TOKEN_TREE => true,
8871 _ => false,
8872 }
8873 }
8874 fn cast(syntax: SyntaxNode) -> Option<Self> {
8875 let res = match syntax.kind() {
8876 LITERAL => AttrInput::Literal(Literal { syntax }),
8877 TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }),
8878 _ => return None,
8879 };
8880 Some(res)
8881 }
8882 fn syntax(&self) -> &SyntaxNode {
8883 match self {
8884 AttrInput::Literal(it) => &it.syntax,
8885 AttrInput::TokenTree(it) => &it.syntax,
8886 }
8887 }
8888}
8889#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8890pub enum Stmt {
8891 LetStmt(LetStmt),
8892 ExprStmt(ExprStmt),
8893}
8894impl From<LetStmt> for Stmt {
8895 fn from(node: LetStmt) -> Stmt {
8896 Stmt::LetStmt(node)
8897 }
8898}
8899impl From<ExprStmt> for Stmt {
8900 fn from(node: ExprStmt) -> Stmt {
8901 Stmt::ExprStmt(node)
8902 }
8903}
8904impl std::fmt::Display for Stmt {
8905 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8906 std::fmt::Display::fmt(self.syntax(), f)
8907 }
8908}
8909impl AstNode for Stmt {
8910 fn can_cast(kind: SyntaxKind) -> bool {
8911 match kind {
8912 LET_STMT | EXPR_STMT => true,
8913 _ => false,
8914 }
8915 }
8916 fn cast(syntax: SyntaxNode) -> Option<Self> {
8917 let res = match syntax.kind() {
8918 LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
8919 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
8920 _ => return None,
8921 };
8922 Some(res)
8923 }
8924 fn syntax(&self) -> &SyntaxNode {
8925 match self {
8926 Stmt::LetStmt(it) => &it.syntax,
8927 Stmt::ExprStmt(it) => &it.syntax,
8928 }
8929 }
8930}
8931#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8932pub enum LeftDelimiter {
8933 LParen(LParen),
8934 LBrack(LBrack),
8935 LCurly(LCurly),
8936}
8937impl From<LParen> for LeftDelimiter {
8938 fn from(node: LParen) -> LeftDelimiter {
8939 LeftDelimiter::LParen(node)
8940 }
8941}
8942impl From<LBrack> for LeftDelimiter {
8943 fn from(node: LBrack) -> LeftDelimiter {
8944 LeftDelimiter::LBrack(node)
8945 }
8946}
8947impl From<LCurly> for LeftDelimiter {
8948 fn from(node: LCurly) -> LeftDelimiter {
8949 LeftDelimiter::LCurly(node)
8950 }
8951}
8952impl std::fmt::Display for LeftDelimiter {
8953 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8954 std::fmt::Display::fmt(self.syntax(), f)
8955 }
8956}
8957impl AstToken for LeftDelimiter {
8958 fn can_cast(kind: SyntaxKind) -> bool {
8959 match kind {
8960 L_PAREN | L_BRACK | L_CURLY => true,
8961 _ => false,
8962 }
8963 }
8964 fn cast(syntax: SyntaxToken) -> Option<Self> {
8965 let res = match syntax.kind() {
8966 L_PAREN => LeftDelimiter::LParen(LParen { syntax }),
8967 L_BRACK => LeftDelimiter::LBrack(LBrack { syntax }),
8968 L_CURLY => LeftDelimiter::LCurly(LCurly { syntax }),
8969 _ => return None,
8970 };
8971 Some(res)
8972 }
8973 fn syntax(&self) -> &SyntaxToken {
8974 match self {
8975 LeftDelimiter::LParen(it) => &it.syntax,
8976 LeftDelimiter::LBrack(it) => &it.syntax,
8977 LeftDelimiter::LCurly(it) => &it.syntax,
8978 }
8979 }
8980}
8981#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8982pub enum RightDelimiter {
8983 RParen(RParen),
8984 RBrack(RBrack),
8985 RCurly(RCurly),
8986}
8987impl From<RParen> for RightDelimiter {
8988 fn from(node: RParen) -> RightDelimiter {
8989 RightDelimiter::RParen(node)
8990 }
8991}
8992impl From<RBrack> for RightDelimiter {
8993 fn from(node: RBrack) -> RightDelimiter {
8994 RightDelimiter::RBrack(node)
8995 }
8996}
8997impl From<RCurly> for RightDelimiter {
8998 fn from(node: RCurly) -> RightDelimiter {
8999 RightDelimiter::RCurly(node)
9000 }
9001}
9002impl std::fmt::Display for RightDelimiter {
9003 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9004 std::fmt::Display::fmt(self.syntax(), f)
9005 }
9006}
9007impl AstToken for RightDelimiter {
9008 fn can_cast(kind: SyntaxKind) -> bool {
9009 match kind {
9010 R_PAREN | R_BRACK | R_CURLY => true,
9011 _ => false,
9012 }
9013 }
9014 fn cast(syntax: SyntaxToken) -> Option<Self> {
9015 let res = match syntax.kind() {
9016 R_PAREN => RightDelimiter::RParen(RParen { syntax }),
9017 R_BRACK => RightDelimiter::RBrack(RBrack { syntax }),
9018 R_CURLY => RightDelimiter::RCurly(RCurly { syntax }),
9019 _ => return None,
9020 };
9021 Some(res)
9022 }
9023 fn syntax(&self) -> &SyntaxToken {
9024 match self {
9025 RightDelimiter::RParen(it) => &it.syntax,
9026 RightDelimiter::RBrack(it) => &it.syntax,
9027 RightDelimiter::RCurly(it) => &it.syntax,
9028 }
9029 }
9030}
9031#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9032pub enum RangeSeparator {
9033 Dotdot(Dotdot),
9034 Dotdotdot(Dotdotdot),
9035 Dotdoteq(Dotdoteq),
9036}
9037impl From<Dotdot> for RangeSeparator {
9038 fn from(node: Dotdot) -> RangeSeparator {
9039 RangeSeparator::Dotdot(node)
9040 }
9041}
9042impl From<Dotdotdot> for RangeSeparator {
9043 fn from(node: Dotdotdot) -> RangeSeparator {
9044 RangeSeparator::Dotdotdot(node)
9045 }
9046}
9047impl From<Dotdoteq> for RangeSeparator {
9048 fn from(node: Dotdoteq) -> RangeSeparator {
9049 RangeSeparator::Dotdoteq(node)
9050 }
9051}
9052impl std::fmt::Display for RangeSeparator {
9053 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9054 std::fmt::Display::fmt(self.syntax(), f)
9055 }
9056}
9057impl AstToken for RangeSeparator {
9058 fn can_cast(kind: SyntaxKind) -> bool {
9059 match kind {
9060 DOTDOT | DOTDOTDOT | DOTDOTEQ => true,
9061 _ => false,
9062 }
9063 }
9064 fn cast(syntax: SyntaxToken) -> Option<Self> {
9065 let res = match syntax.kind() {
9066 DOTDOT => RangeSeparator::Dotdot(Dotdot { syntax }),
9067 DOTDOTDOT => RangeSeparator::Dotdotdot(Dotdotdot { syntax }),
9068 DOTDOTEQ => RangeSeparator::Dotdoteq(Dotdoteq { syntax }),
9069 _ => return None,
9070 };
9071 Some(res)
9072 }
9073 fn syntax(&self) -> &SyntaxToken {
9074 match self {
9075 RangeSeparator::Dotdot(it) => &it.syntax,
9076 RangeSeparator::Dotdotdot(it) => &it.syntax,
9077 RangeSeparator::Dotdoteq(it) => &it.syntax,
9078 }
9079 }
9080}
9081#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9082pub enum BinOp {
9083 Pipepipe(Pipepipe),
9084 Ampamp(Ampamp),
9085 Eqeq(Eqeq),
9086 Neq(Neq),
9087 Lteq(Lteq),
9088 Gteq(Gteq),
9089 LAngle(LAngle),
9090 RAngle(RAngle),
9091 Plus(Plus),
9092 Star(Star),
9093 Minus(Minus),
9094 Slash(Slash),
9095 Percent(Percent),
9096 Shl(Shl),
9097 Shr(Shr),
9098 Caret(Caret),
9099 Pipe(Pipe),
9100 Amp(Amp),
9101 Eq(Eq),
9102 Pluseq(Pluseq),
9103 Slasheq(Slasheq),
9104 Stareq(Stareq),
9105 Percenteq(Percenteq),
9106 Shreq(Shreq),
9107 Shleq(Shleq),
9108 Minuseq(Minuseq),
9109 Pipeeq(Pipeeq),
9110 Ampeq(Ampeq),
9111 Careteq(Careteq),
9112}
9113impl From<Pipepipe> for BinOp {
9114 fn from(node: Pipepipe) -> BinOp {
9115 BinOp::Pipepipe(node)
9116 }
9117}
9118impl From<Ampamp> for BinOp {
9119 fn from(node: Ampamp) -> BinOp {
9120 BinOp::Ampamp(node)
9121 }
9122}
9123impl From<Eqeq> for BinOp {
9124 fn from(node: Eqeq) -> BinOp {
9125 BinOp::Eqeq(node)
9126 }
9127}
9128impl From<Neq> for BinOp {
9129 fn from(node: Neq) -> BinOp {
9130 BinOp::Neq(node)
9131 }
9132}
9133impl From<Lteq> for BinOp {
9134 fn from(node: Lteq) -> BinOp {
9135 BinOp::Lteq(node)
9136 }
9137}
9138impl From<Gteq> for BinOp {
9139 fn from(node: Gteq) -> BinOp {
9140 BinOp::Gteq(node)
9141 }
9142}
9143impl From<LAngle> for BinOp {
9144 fn from(node: LAngle) -> BinOp {
9145 BinOp::LAngle(node)
9146 }
9147}
9148impl From<RAngle> for BinOp {
9149 fn from(node: RAngle) -> BinOp {
9150 BinOp::RAngle(node)
9151 }
9152}
9153impl From<Plus> for BinOp {
9154 fn from(node: Plus) -> BinOp {
9155 BinOp::Plus(node)
9156 }
9157}
9158impl From<Star> for BinOp {
9159 fn from(node: Star) -> BinOp {
9160 BinOp::Star(node)
9161 }
9162}
9163impl From<Minus> for BinOp {
9164 fn from(node: Minus) -> BinOp {
9165 BinOp::Minus(node)
9166 }
9167}
9168impl From<Slash> for BinOp {
9169 fn from(node: Slash) -> BinOp {
9170 BinOp::Slash(node)
9171 }
9172}
9173impl From<Percent> for BinOp {
9174 fn from(node: Percent) -> BinOp {
9175 BinOp::Percent(node)
9176 }
9177}
9178impl From<Shl> for BinOp {
9179 fn from(node: Shl) -> BinOp {
9180 BinOp::Shl(node)
9181 }
9182}
9183impl From<Shr> for BinOp {
9184 fn from(node: Shr) -> BinOp {
9185 BinOp::Shr(node)
9186 }
9187}
9188impl From<Caret> for BinOp {
9189 fn from(node: Caret) -> BinOp {
9190 BinOp::Caret(node)
9191 }
9192}
9193impl From<Pipe> for BinOp {
9194 fn from(node: Pipe) -> BinOp {
9195 BinOp::Pipe(node)
9196 }
9197}
9198impl From<Amp> for BinOp {
9199 fn from(node: Amp) -> BinOp {
9200 BinOp::Amp(node)
9201 }
9202}
9203impl From<Eq> for BinOp {
9204 fn from(node: Eq) -> BinOp {
9205 BinOp::Eq(node)
9206 }
9207}
9208impl From<Pluseq> for BinOp {
9209 fn from(node: Pluseq) -> BinOp {
9210 BinOp::Pluseq(node)
9211 }
9212}
9213impl From<Slasheq> for BinOp {
9214 fn from(node: Slasheq) -> BinOp {
9215 BinOp::Slasheq(node)
9216 }
9217}
9218impl From<Stareq> for BinOp {
9219 fn from(node: Stareq) -> BinOp {
9220 BinOp::Stareq(node)
9221 }
9222}
9223impl From<Percenteq> for BinOp {
9224 fn from(node: Percenteq) -> BinOp {
9225 BinOp::Percenteq(node)
9226 }
9227}
9228impl From<Shreq> for BinOp {
9229 fn from(node: Shreq) -> BinOp {
9230 BinOp::Shreq(node)
9231 }
9232}
9233impl From<Shleq> for BinOp {
9234 fn from(node: Shleq) -> BinOp {
9235 BinOp::Shleq(node)
9236 }
9237}
9238impl From<Minuseq> for BinOp {
9239 fn from(node: Minuseq) -> BinOp {
9240 BinOp::Minuseq(node)
9241 }
9242}
9243impl From<Pipeeq> for BinOp {
9244 fn from(node: Pipeeq) -> BinOp {
9245 BinOp::Pipeeq(node)
9246 }
9247}
9248impl From<Ampeq> for BinOp {
9249 fn from(node: Ampeq) -> BinOp {
9250 BinOp::Ampeq(node)
9251 }
9252}
9253impl From<Careteq> for BinOp {
9254 fn from(node: Careteq) -> BinOp {
9255 BinOp::Careteq(node)
9256 }
9257}
9258impl std::fmt::Display for BinOp {
9259 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9260 std::fmt::Display::fmt(self.syntax(), f)
9261 }
9262}
9263impl AstToken for BinOp {
9264 fn can_cast(kind: SyntaxKind) -> bool {
9265 match kind {
9266 PIPEPIPE | AMPAMP | EQEQ | NEQ | LTEQ | GTEQ | L_ANGLE | R_ANGLE | PLUS | STAR
9267 | MINUS | SLASH | PERCENT | SHL | SHR | CARET | PIPE | AMP | EQ | PLUSEQ | SLASHEQ
9268 | STAREQ | PERCENTEQ | SHREQ | SHLEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ => true,
9269 _ => false,
9270 }
9271 }
9272 fn cast(syntax: SyntaxToken) -> Option<Self> {
9273 let res = match syntax.kind() {
9274 PIPEPIPE => BinOp::Pipepipe(Pipepipe { syntax }),
9275 AMPAMP => BinOp::Ampamp(Ampamp { syntax }),
9276 EQEQ => BinOp::Eqeq(Eqeq { syntax }),
9277 NEQ => BinOp::Neq(Neq { syntax }),
9278 LTEQ => BinOp::Lteq(Lteq { syntax }),
9279 GTEQ => BinOp::Gteq(Gteq { syntax }),
9280 L_ANGLE => BinOp::LAngle(LAngle { syntax }),
9281 R_ANGLE => BinOp::RAngle(RAngle { syntax }),
9282 PLUS => BinOp::Plus(Plus { syntax }),
9283 STAR => BinOp::Star(Star { syntax }),
9284 MINUS => BinOp::Minus(Minus { syntax }),
9285 SLASH => BinOp::Slash(Slash { syntax }),
9286 PERCENT => BinOp::Percent(Percent { syntax }),
9287 SHL => BinOp::Shl(Shl { syntax }),
9288 SHR => BinOp::Shr(Shr { syntax }),
9289 CARET => BinOp::Caret(Caret { syntax }),
9290 PIPE => BinOp::Pipe(Pipe { syntax }),
9291 AMP => BinOp::Amp(Amp { syntax }),
9292 EQ => BinOp::Eq(Eq { syntax }),
9293 PLUSEQ => BinOp::Pluseq(Pluseq { syntax }),
9294 SLASHEQ => BinOp::Slasheq(Slasheq { syntax }),
9295 STAREQ => BinOp::Stareq(Stareq { syntax }),
9296 PERCENTEQ => BinOp::Percenteq(Percenteq { syntax }),
9297 SHREQ => BinOp::Shreq(Shreq { syntax }),
9298 SHLEQ => BinOp::Shleq(Shleq { syntax }),
9299 MINUSEQ => BinOp::Minuseq(Minuseq { syntax }),
9300 PIPEEQ => BinOp::Pipeeq(Pipeeq { syntax }),
9301 AMPEQ => BinOp::Ampeq(Ampeq { syntax }),
9302 CARETEQ => BinOp::Careteq(Careteq { syntax }),
9303 _ => return None,
9304 };
9305 Some(res)
9306 }
9307 fn syntax(&self) -> &SyntaxToken {
9308 match self {
9309 BinOp::Pipepipe(it) => &it.syntax,
9310 BinOp::Ampamp(it) => &it.syntax,
9311 BinOp::Eqeq(it) => &it.syntax,
9312 BinOp::Neq(it) => &it.syntax,
9313 BinOp::Lteq(it) => &it.syntax,
9314 BinOp::Gteq(it) => &it.syntax,
9315 BinOp::LAngle(it) => &it.syntax,
9316 BinOp::RAngle(it) => &it.syntax,
9317 BinOp::Plus(it) => &it.syntax,
9318 BinOp::Star(it) => &it.syntax,
9319 BinOp::Minus(it) => &it.syntax,
9320 BinOp::Slash(it) => &it.syntax,
9321 BinOp::Percent(it) => &it.syntax,
9322 BinOp::Shl(it) => &it.syntax,
9323 BinOp::Shr(it) => &it.syntax,
9324 BinOp::Caret(it) => &it.syntax,
9325 BinOp::Pipe(it) => &it.syntax,
9326 BinOp::Amp(it) => &it.syntax,
9327 BinOp::Eq(it) => &it.syntax,
9328 BinOp::Pluseq(it) => &it.syntax,
9329 BinOp::Slasheq(it) => &it.syntax,
9330 BinOp::Stareq(it) => &it.syntax,
9331 BinOp::Percenteq(it) => &it.syntax,
9332 BinOp::Shreq(it) => &it.syntax,
9333 BinOp::Shleq(it) => &it.syntax,
9334 BinOp::Minuseq(it) => &it.syntax,
9335 BinOp::Pipeeq(it) => &it.syntax,
9336 BinOp::Ampeq(it) => &it.syntax,
9337 BinOp::Careteq(it) => &it.syntax,
9338 }
9339 }
9340}
9341#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9342pub enum PrefixOp {
9343 Minus(Minus),
9344 Excl(Excl),
9345 Star(Star),
9346}
9347impl From<Minus> for PrefixOp {
9348 fn from(node: Minus) -> PrefixOp {
9349 PrefixOp::Minus(node)
9350 }
9351}
9352impl From<Excl> for PrefixOp {
9353 fn from(node: Excl) -> PrefixOp {
9354 PrefixOp::Excl(node)
9355 }
9356}
9357impl From<Star> for PrefixOp {
9358 fn from(node: Star) -> PrefixOp {
9359 PrefixOp::Star(node)
9360 }
9361}
9362impl std::fmt::Display for PrefixOp {
9363 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9364 std::fmt::Display::fmt(self.syntax(), f)
9365 }
9366}
9367impl AstToken for PrefixOp {
9368 fn can_cast(kind: SyntaxKind) -> bool {
9369 match kind {
9370 MINUS | EXCL | STAR => true,
9371 _ => false,
9372 }
9373 }
9374 fn cast(syntax: SyntaxToken) -> Option<Self> {
9375 let res = match syntax.kind() {
9376 MINUS => PrefixOp::Minus(Minus { syntax }),
9377 EXCL => PrefixOp::Excl(Excl { syntax }),
9378 STAR => PrefixOp::Star(Star { syntax }),
9379 _ => return None,
9380 };
9381 Some(res)
9382 }
9383 fn syntax(&self) -> &SyntaxToken {
9384 match self {
9385 PrefixOp::Minus(it) => &it.syntax,
9386 PrefixOp::Excl(it) => &it.syntax,
9387 PrefixOp::Star(it) => &it.syntax,
9388 }
9389 }
9390}
9391#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9392pub enum RangeOp {
9393 Dotdot(Dotdot),
9394 Dotdoteq(Dotdoteq),
9395}
9396impl From<Dotdot> for RangeOp {
9397 fn from(node: Dotdot) -> RangeOp {
9398 RangeOp::Dotdot(node)
9399 }
9400}
9401impl From<Dotdoteq> for RangeOp {
9402 fn from(node: Dotdoteq) -> RangeOp {
9403 RangeOp::Dotdoteq(node)
9404 }
9405}
9406impl std::fmt::Display for RangeOp {
9407 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9408 std::fmt::Display::fmt(self.syntax(), f)
9409 }
9410}
9411impl AstToken for RangeOp {
9412 fn can_cast(kind: SyntaxKind) -> bool {
9413 match kind {
9414 DOTDOT | DOTDOTEQ => true,
9415 _ => false,
9416 }
9417 }
9418 fn cast(syntax: SyntaxToken) -> Option<Self> {
9419 let res = match syntax.kind() {
9420 DOTDOT => RangeOp::Dotdot(Dotdot { syntax }),
9421 DOTDOTEQ => RangeOp::Dotdoteq(Dotdoteq { syntax }),
9422 _ => return None,
9423 };
9424 Some(res)
9425 }
9426 fn syntax(&self) -> &SyntaxToken {
9427 match self {
9428 RangeOp::Dotdot(it) => &it.syntax,
9429 RangeOp::Dotdoteq(it) => &it.syntax,
9430 }
9431 }
9432}
9433#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9434pub enum LiteralToken {
9435 IntNumber(IntNumber),
9436 FloatNumber(FloatNumber),
9437 String(String),
9438 RawString(RawString),
9439 TrueKw(TrueKw),
9440 FalseKw(FalseKw),
9441 ByteString(ByteString),
9442 RawByteString(RawByteString),
9443 Char(Char),
9444 Byte(Byte),
9445}
9446impl From<IntNumber> for LiteralToken {
9447 fn from(node: IntNumber) -> LiteralToken {
9448 LiteralToken::IntNumber(node)
9449 }
9450}
9451impl From<FloatNumber> for LiteralToken {
9452 fn from(node: FloatNumber) -> LiteralToken {
9453 LiteralToken::FloatNumber(node)
9454 }
9455}
9456impl From<String> for LiteralToken {
9457 fn from(node: String) -> LiteralToken {
9458 LiteralToken::String(node)
9459 }
9460}
9461impl From<RawString> for LiteralToken {
9462 fn from(node: RawString) -> LiteralToken {
9463 LiteralToken::RawString(node)
9464 }
9465}
9466impl From<TrueKw> for LiteralToken {
9467 fn from(node: TrueKw) -> LiteralToken {
9468 LiteralToken::TrueKw(node)
9469 }
9470}
9471impl From<FalseKw> for LiteralToken {
9472 fn from(node: FalseKw) -> LiteralToken {
9473 LiteralToken::FalseKw(node)
9474 }
9475}
9476impl From<ByteString> for LiteralToken {
9477 fn from(node: ByteString) -> LiteralToken {
9478 LiteralToken::ByteString(node)
9479 }
9480}
9481impl From<RawByteString> for LiteralToken {
9482 fn from(node: RawByteString) -> LiteralToken {
9483 LiteralToken::RawByteString(node)
9484 }
9485}
9486impl From<Char> for LiteralToken {
9487 fn from(node: Char) -> LiteralToken {
9488 LiteralToken::Char(node)
9489 }
9490}
9491impl From<Byte> for LiteralToken {
9492 fn from(node: Byte) -> LiteralToken {
9493 LiteralToken::Byte(node)
9494 }
9495}
9496impl std::fmt::Display for LiteralToken {
9497 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9498 std::fmt::Display::fmt(self.syntax(), f)
9499 }
9500}
9501impl AstToken for LiteralToken {
9502 fn can_cast(kind: SyntaxKind) -> bool {
9503 match kind {
9504 INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | TRUE_KW | FALSE_KW | BYTE_STRING
9505 | RAW_BYTE_STRING | CHAR | BYTE => true,
9506 _ => false,
9507 }
9508 }
9509 fn cast(syntax: SyntaxToken) -> Option<Self> {
9510 let res = match syntax.kind() {
9511 INT_NUMBER => LiteralToken::IntNumber(IntNumber { syntax }),
9512 FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }),
9513 STRING => LiteralToken::String(String { syntax }),
9514 RAW_STRING => LiteralToken::RawString(RawString { syntax }),
9515 TRUE_KW => LiteralToken::TrueKw(TrueKw { syntax }),
9516 FALSE_KW => LiteralToken::FalseKw(FalseKw { syntax }),
9517 BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }),
9518 RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }),
9519 CHAR => LiteralToken::Char(Char { syntax }),
9520 BYTE => LiteralToken::Byte(Byte { syntax }),
9521 _ => return None,
9522 };
9523 Some(res)
9524 }
9525 fn syntax(&self) -> &SyntaxToken {
9526 match self {
9527 LiteralToken::IntNumber(it) => &it.syntax,
9528 LiteralToken::FloatNumber(it) => &it.syntax,
9529 LiteralToken::String(it) => &it.syntax,
9530 LiteralToken::RawString(it) => &it.syntax,
9531 LiteralToken::TrueKw(it) => &it.syntax,
9532 LiteralToken::FalseKw(it) => &it.syntax,
9533 LiteralToken::ByteString(it) => &it.syntax,
9534 LiteralToken::RawByteString(it) => &it.syntax,
9535 LiteralToken::Char(it) => &it.syntax,
9536 LiteralToken::Byte(it) => &it.syntax,
9537 }
9538 }
9539}
9540#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9541pub enum NameRefToken {
9542 Ident(Ident),
9543 IntNumber(IntNumber),
9544}
9545impl From<Ident> for NameRefToken {
9546 fn from(node: Ident) -> NameRefToken {
9547 NameRefToken::Ident(node)
9548 }
9549}
9550impl From<IntNumber> for NameRefToken {
9551 fn from(node: IntNumber) -> NameRefToken {
9552 NameRefToken::IntNumber(node)
9553 }
9554}
9555impl std::fmt::Display for NameRefToken {
9556 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9557 std::fmt::Display::fmt(self.syntax(), f)
9558 }
9559}
9560impl AstToken for NameRefToken {
9561 fn can_cast(kind: SyntaxKind) -> bool {
9562 match kind {
9563 IDENT | INT_NUMBER => true,
9564 _ => false,
9565 }
9566 }
9567 fn cast(syntax: SyntaxToken) -> Option<Self> {
9568 let res = match syntax.kind() {
9569 IDENT => NameRefToken::Ident(Ident { syntax }),
9570 INT_NUMBER => NameRefToken::IntNumber(IntNumber { syntax }),
9571 _ => return None,
9572 };
9573 Some(res)
9574 }
9575 fn syntax(&self) -> &SyntaxToken {
9576 match self {
9577 NameRefToken::Ident(it) => &it.syntax,
9578 NameRefToken::IntNumber(it) => &it.syntax,
9579 }
9580 }
9581}
9582#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9583pub enum FieldDefList {
9584 RecordFieldDefList(RecordFieldDefList),
9585 TupleFieldDefList(TupleFieldDefList),
9586}
9587impl From<RecordFieldDefList> for FieldDefList {
9588 fn from(node: RecordFieldDefList) -> FieldDefList {
9589 FieldDefList::RecordFieldDefList(node)
9590 }
9591}
9592impl From<TupleFieldDefList> for FieldDefList {
9593 fn from(node: TupleFieldDefList) -> FieldDefList {
9594 FieldDefList::TupleFieldDefList(node)
9595 }
9596}
9597impl std::fmt::Display for FieldDefList {
9598 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9599 std::fmt::Display::fmt(self.syntax(), f)
9600 }
9601}
9602impl AstNode for FieldDefList {
9603 fn can_cast(kind: SyntaxKind) -> bool {
9604 match kind {
9605 RECORD_FIELD_DEF_LIST | TUPLE_FIELD_DEF_LIST => true,
9606 _ => false,
9607 }
9608 }
9609 fn cast(syntax: SyntaxNode) -> Option<Self> {
9610 let res = match syntax.kind() {
9611 RECORD_FIELD_DEF_LIST => {
9612 FieldDefList::RecordFieldDefList(RecordFieldDefList { syntax })
9613 }
9614 TUPLE_FIELD_DEF_LIST => FieldDefList::TupleFieldDefList(TupleFieldDefList { syntax }),
9615 _ => return None,
9616 };
9617 Some(res)
9618 }
9619 fn syntax(&self) -> &SyntaxNode {
9620 match self {
9621 FieldDefList::RecordFieldDefList(it) => &it.syntax,
9622 FieldDefList::TupleFieldDefList(it) => &it.syntax,
9623 }
9624 }
9625}
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs
index 104399f7f..e6ba2009c 100644
--- a/xtask/src/codegen.rs
+++ b/xtask/src/codegen.rs
@@ -23,7 +23,7 @@ const OK_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/ok";
23const ERR_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/err"; 23const ERR_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/err";
24 24
25const SYNTAX_KINDS: &str = "crates/ra_parser/src/syntax_kind/generated.rs"; 25const SYNTAX_KINDS: &str = "crates/ra_parser/src/syntax_kind/generated.rs";
26const AST: &str = "crates/ra_syntax/src/ast/generated.rs"; 26const AST_NODES: &str = "crates/ra_syntax/src/ast/generated/nodes.rs";
27 27
28const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers"; 28const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers";
29const ASSISTS_TESTS: &str = "crates/ra_assists/src/doc_tests/generated.rs"; 29const ASSISTS_TESTS: &str = "crates/ra_assists/src/doc_tests/generated.rs";
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs
index af7d4ffac..c2734d638 100644
--- a/xtask/src/codegen/gen_syntax.rs
+++ b/xtask/src/codegen/gen_syntax.rs
@@ -22,7 +22,7 @@ pub fn generate_syntax(mode: Mode) -> Result<()> {
22 let syntax_kinds = generate_syntax_kinds(KINDS_SRC)?; 22 let syntax_kinds = generate_syntax_kinds(KINDS_SRC)?;
23 update(syntax_kinds_file.as_path(), &syntax_kinds, mode)?; 23 update(syntax_kinds_file.as_path(), &syntax_kinds, mode)?;
24 24
25 let ast_file = project_root().join(codegen::AST); 25 let ast_file = project_root().join(codegen::AST_NODES);
26 let ast = generate_ast(KINDS_SRC, AST_SRC)?; 26 let ast = generate_ast(KINDS_SRC, AST_SRC)?;
27 update(ast_file.as_path(), &ast, mode)?; 27 update(ast_file.as_path(), &ast, mode)?;
28 28