Skip to main content

rustpython_ruff_python_ast/
generated.rs

1// This is a generated file. Don't modify it by hand!
2// Run `crates/ruff_python_ast/generate.py` to re-generate the file.
3
4use crate::name::Name;
5use crate::visitor::source_order::SourceOrderVisitor;
6
7/// See also [mod](https://docs.python.org/3/library/ast.html#ast.mod)
8#[derive(Clone, Debug, PartialEq)]
9#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
10pub enum Mod {
11    Module(crate::ModModule),
12    Expression(crate::ModExpression),
13}
14
15impl From<crate::ModModule> for Mod {
16    fn from(node: crate::ModModule) -> Self {
17        Self::Module(node)
18    }
19}
20
21impl From<crate::ModExpression> for Mod {
22    fn from(node: crate::ModExpression) -> Self {
23        Self::Expression(node)
24    }
25}
26
27impl ruff_text_size::Ranged for Mod {
28    fn range(&self) -> ruff_text_size::TextRange {
29        match self {
30            Self::Module(node) => node.range(),
31            Self::Expression(node) => node.range(),
32        }
33    }
34}
35
36impl crate::HasNodeIndex for Mod {
37    fn node_index(&self) -> &crate::AtomicNodeIndex {
38        match self {
39            Self::Module(node) => node.node_index(),
40            Self::Expression(node) => node.node_index(),
41        }
42    }
43}
44
45#[allow(dead_code, clippy::match_wildcard_for_single_variants)]
46impl Mod {
47    #[inline]
48    pub const fn is_module(&self) -> bool {
49        matches!(self, Self::Module(_))
50    }
51
52    #[inline]
53    pub fn module(self) -> Option<crate::ModModule> {
54        match self {
55            Self::Module(val) => Some(val),
56            _ => None,
57        }
58    }
59
60    #[inline]
61    pub fn expect_module(self) -> crate::ModModule {
62        match self {
63            Self::Module(val) => val,
64            _ => panic!("called expect on {self:?}"),
65        }
66    }
67
68    #[inline]
69    pub fn as_module_mut(&mut self) -> Option<&mut crate::ModModule> {
70        match self {
71            Self::Module(val) => Some(val),
72            _ => None,
73        }
74    }
75
76    #[inline]
77    pub fn as_module(&self) -> Option<&crate::ModModule> {
78        match self {
79            Self::Module(val) => Some(val),
80            _ => None,
81        }
82    }
83
84    #[inline]
85    pub const fn is_expression(&self) -> bool {
86        matches!(self, Self::Expression(_))
87    }
88
89    #[inline]
90    pub fn expression(self) -> Option<crate::ModExpression> {
91        match self {
92            Self::Expression(val) => Some(val),
93            _ => None,
94        }
95    }
96
97    #[inline]
98    pub fn expect_expression(self) -> crate::ModExpression {
99        match self {
100            Self::Expression(val) => val,
101            _ => panic!("called expect on {self:?}"),
102        }
103    }
104
105    #[inline]
106    pub fn as_expression_mut(&mut self) -> Option<&mut crate::ModExpression> {
107        match self {
108            Self::Expression(val) => Some(val),
109            _ => None,
110        }
111    }
112
113    #[inline]
114    pub fn as_expression(&self) -> Option<&crate::ModExpression> {
115        match self {
116            Self::Expression(val) => Some(val),
117            _ => None,
118        }
119    }
120}
121
122/// See also [stmt](https://docs.python.org/3/library/ast.html#ast.stmt)
123#[derive(Clone, Debug, PartialEq)]
124#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
125pub enum Stmt {
126    FunctionDef(crate::StmtFunctionDef),
127    ClassDef(crate::StmtClassDef),
128    Return(crate::StmtReturn),
129    Delete(crate::StmtDelete),
130    TypeAlias(crate::StmtTypeAlias),
131    Assign(crate::StmtAssign),
132    AugAssign(crate::StmtAugAssign),
133    AnnAssign(crate::StmtAnnAssign),
134    For(crate::StmtFor),
135    While(crate::StmtWhile),
136    If(crate::StmtIf),
137    With(crate::StmtWith),
138    Match(crate::StmtMatch),
139    Raise(crate::StmtRaise),
140    Try(crate::StmtTry),
141    Assert(crate::StmtAssert),
142    Import(crate::StmtImport),
143    ImportFrom(crate::StmtImportFrom),
144    Global(crate::StmtGlobal),
145    Nonlocal(crate::StmtNonlocal),
146    Expr(crate::StmtExpr),
147    Pass(crate::StmtPass),
148    Break(crate::StmtBreak),
149    Continue(crate::StmtContinue),
150    IpyEscapeCommand(crate::StmtIpyEscapeCommand),
151}
152
153impl From<crate::StmtFunctionDef> for Stmt {
154    fn from(node: crate::StmtFunctionDef) -> Self {
155        Self::FunctionDef(node)
156    }
157}
158
159impl From<crate::StmtClassDef> for Stmt {
160    fn from(node: crate::StmtClassDef) -> Self {
161        Self::ClassDef(node)
162    }
163}
164
165impl From<crate::StmtReturn> for Stmt {
166    fn from(node: crate::StmtReturn) -> Self {
167        Self::Return(node)
168    }
169}
170
171impl From<crate::StmtDelete> for Stmt {
172    fn from(node: crate::StmtDelete) -> Self {
173        Self::Delete(node)
174    }
175}
176
177impl From<crate::StmtTypeAlias> for Stmt {
178    fn from(node: crate::StmtTypeAlias) -> Self {
179        Self::TypeAlias(node)
180    }
181}
182
183impl From<crate::StmtAssign> for Stmt {
184    fn from(node: crate::StmtAssign) -> Self {
185        Self::Assign(node)
186    }
187}
188
189impl From<crate::StmtAugAssign> for Stmt {
190    fn from(node: crate::StmtAugAssign) -> Self {
191        Self::AugAssign(node)
192    }
193}
194
195impl From<crate::StmtAnnAssign> for Stmt {
196    fn from(node: crate::StmtAnnAssign) -> Self {
197        Self::AnnAssign(node)
198    }
199}
200
201impl From<crate::StmtFor> for Stmt {
202    fn from(node: crate::StmtFor) -> Self {
203        Self::For(node)
204    }
205}
206
207impl From<crate::StmtWhile> for Stmt {
208    fn from(node: crate::StmtWhile) -> Self {
209        Self::While(node)
210    }
211}
212
213impl From<crate::StmtIf> for Stmt {
214    fn from(node: crate::StmtIf) -> Self {
215        Self::If(node)
216    }
217}
218
219impl From<crate::StmtWith> for Stmt {
220    fn from(node: crate::StmtWith) -> Self {
221        Self::With(node)
222    }
223}
224
225impl From<crate::StmtMatch> for Stmt {
226    fn from(node: crate::StmtMatch) -> Self {
227        Self::Match(node)
228    }
229}
230
231impl From<crate::StmtRaise> for Stmt {
232    fn from(node: crate::StmtRaise) -> Self {
233        Self::Raise(node)
234    }
235}
236
237impl From<crate::StmtTry> for Stmt {
238    fn from(node: crate::StmtTry) -> Self {
239        Self::Try(node)
240    }
241}
242
243impl From<crate::StmtAssert> for Stmt {
244    fn from(node: crate::StmtAssert) -> Self {
245        Self::Assert(node)
246    }
247}
248
249impl From<crate::StmtImport> for Stmt {
250    fn from(node: crate::StmtImport) -> Self {
251        Self::Import(node)
252    }
253}
254
255impl From<crate::StmtImportFrom> for Stmt {
256    fn from(node: crate::StmtImportFrom) -> Self {
257        Self::ImportFrom(node)
258    }
259}
260
261impl From<crate::StmtGlobal> for Stmt {
262    fn from(node: crate::StmtGlobal) -> Self {
263        Self::Global(node)
264    }
265}
266
267impl From<crate::StmtNonlocal> for Stmt {
268    fn from(node: crate::StmtNonlocal) -> Self {
269        Self::Nonlocal(node)
270    }
271}
272
273impl From<crate::StmtExpr> for Stmt {
274    fn from(node: crate::StmtExpr) -> Self {
275        Self::Expr(node)
276    }
277}
278
279impl From<crate::StmtPass> for Stmt {
280    fn from(node: crate::StmtPass) -> Self {
281        Self::Pass(node)
282    }
283}
284
285impl From<crate::StmtBreak> for Stmt {
286    fn from(node: crate::StmtBreak) -> Self {
287        Self::Break(node)
288    }
289}
290
291impl From<crate::StmtContinue> for Stmt {
292    fn from(node: crate::StmtContinue) -> Self {
293        Self::Continue(node)
294    }
295}
296
297impl From<crate::StmtIpyEscapeCommand> for Stmt {
298    fn from(node: crate::StmtIpyEscapeCommand) -> Self {
299        Self::IpyEscapeCommand(node)
300    }
301}
302
303impl ruff_text_size::Ranged for Stmt {
304    fn range(&self) -> ruff_text_size::TextRange {
305        match self {
306            Self::FunctionDef(node) => node.range(),
307            Self::ClassDef(node) => node.range(),
308            Self::Return(node) => node.range(),
309            Self::Delete(node) => node.range(),
310            Self::TypeAlias(node) => node.range(),
311            Self::Assign(node) => node.range(),
312            Self::AugAssign(node) => node.range(),
313            Self::AnnAssign(node) => node.range(),
314            Self::For(node) => node.range(),
315            Self::While(node) => node.range(),
316            Self::If(node) => node.range(),
317            Self::With(node) => node.range(),
318            Self::Match(node) => node.range(),
319            Self::Raise(node) => node.range(),
320            Self::Try(node) => node.range(),
321            Self::Assert(node) => node.range(),
322            Self::Import(node) => node.range(),
323            Self::ImportFrom(node) => node.range(),
324            Self::Global(node) => node.range(),
325            Self::Nonlocal(node) => node.range(),
326            Self::Expr(node) => node.range(),
327            Self::Pass(node) => node.range(),
328            Self::Break(node) => node.range(),
329            Self::Continue(node) => node.range(),
330            Self::IpyEscapeCommand(node) => node.range(),
331        }
332    }
333}
334
335impl crate::HasNodeIndex for Stmt {
336    fn node_index(&self) -> &crate::AtomicNodeIndex {
337        match self {
338            Self::FunctionDef(node) => node.node_index(),
339            Self::ClassDef(node) => node.node_index(),
340            Self::Return(node) => node.node_index(),
341            Self::Delete(node) => node.node_index(),
342            Self::TypeAlias(node) => node.node_index(),
343            Self::Assign(node) => node.node_index(),
344            Self::AugAssign(node) => node.node_index(),
345            Self::AnnAssign(node) => node.node_index(),
346            Self::For(node) => node.node_index(),
347            Self::While(node) => node.node_index(),
348            Self::If(node) => node.node_index(),
349            Self::With(node) => node.node_index(),
350            Self::Match(node) => node.node_index(),
351            Self::Raise(node) => node.node_index(),
352            Self::Try(node) => node.node_index(),
353            Self::Assert(node) => node.node_index(),
354            Self::Import(node) => node.node_index(),
355            Self::ImportFrom(node) => node.node_index(),
356            Self::Global(node) => node.node_index(),
357            Self::Nonlocal(node) => node.node_index(),
358            Self::Expr(node) => node.node_index(),
359            Self::Pass(node) => node.node_index(),
360            Self::Break(node) => node.node_index(),
361            Self::Continue(node) => node.node_index(),
362            Self::IpyEscapeCommand(node) => node.node_index(),
363        }
364    }
365}
366
367#[allow(dead_code, clippy::match_wildcard_for_single_variants)]
368impl Stmt {
369    #[inline]
370    pub const fn is_function_def_stmt(&self) -> bool {
371        matches!(self, Self::FunctionDef(_))
372    }
373
374    #[inline]
375    pub fn function_def_stmt(self) -> Option<crate::StmtFunctionDef> {
376        match self {
377            Self::FunctionDef(val) => Some(val),
378            _ => None,
379        }
380    }
381
382    #[inline]
383    pub fn expect_function_def_stmt(self) -> crate::StmtFunctionDef {
384        match self {
385            Self::FunctionDef(val) => val,
386            _ => panic!("called expect on {self:?}"),
387        }
388    }
389
390    #[inline]
391    pub fn as_function_def_stmt_mut(&mut self) -> Option<&mut crate::StmtFunctionDef> {
392        match self {
393            Self::FunctionDef(val) => Some(val),
394            _ => None,
395        }
396    }
397
398    #[inline]
399    pub fn as_function_def_stmt(&self) -> Option<&crate::StmtFunctionDef> {
400        match self {
401            Self::FunctionDef(val) => Some(val),
402            _ => None,
403        }
404    }
405
406    #[inline]
407    pub const fn is_class_def_stmt(&self) -> bool {
408        matches!(self, Self::ClassDef(_))
409    }
410
411    #[inline]
412    pub fn class_def_stmt(self) -> Option<crate::StmtClassDef> {
413        match self {
414            Self::ClassDef(val) => Some(val),
415            _ => None,
416        }
417    }
418
419    #[inline]
420    pub fn expect_class_def_stmt(self) -> crate::StmtClassDef {
421        match self {
422            Self::ClassDef(val) => val,
423            _ => panic!("called expect on {self:?}"),
424        }
425    }
426
427    #[inline]
428    pub fn as_class_def_stmt_mut(&mut self) -> Option<&mut crate::StmtClassDef> {
429        match self {
430            Self::ClassDef(val) => Some(val),
431            _ => None,
432        }
433    }
434
435    #[inline]
436    pub fn as_class_def_stmt(&self) -> Option<&crate::StmtClassDef> {
437        match self {
438            Self::ClassDef(val) => Some(val),
439            _ => None,
440        }
441    }
442
443    #[inline]
444    pub const fn is_return_stmt(&self) -> bool {
445        matches!(self, Self::Return(_))
446    }
447
448    #[inline]
449    pub fn return_stmt(self) -> Option<crate::StmtReturn> {
450        match self {
451            Self::Return(val) => Some(val),
452            _ => None,
453        }
454    }
455
456    #[inline]
457    pub fn expect_return_stmt(self) -> crate::StmtReturn {
458        match self {
459            Self::Return(val) => val,
460            _ => panic!("called expect on {self:?}"),
461        }
462    }
463
464    #[inline]
465    pub fn as_return_stmt_mut(&mut self) -> Option<&mut crate::StmtReturn> {
466        match self {
467            Self::Return(val) => Some(val),
468            _ => None,
469        }
470    }
471
472    #[inline]
473    pub fn as_return_stmt(&self) -> Option<&crate::StmtReturn> {
474        match self {
475            Self::Return(val) => Some(val),
476            _ => None,
477        }
478    }
479
480    #[inline]
481    pub const fn is_delete_stmt(&self) -> bool {
482        matches!(self, Self::Delete(_))
483    }
484
485    #[inline]
486    pub fn delete_stmt(self) -> Option<crate::StmtDelete> {
487        match self {
488            Self::Delete(val) => Some(val),
489            _ => None,
490        }
491    }
492
493    #[inline]
494    pub fn expect_delete_stmt(self) -> crate::StmtDelete {
495        match self {
496            Self::Delete(val) => val,
497            _ => panic!("called expect on {self:?}"),
498        }
499    }
500
501    #[inline]
502    pub fn as_delete_stmt_mut(&mut self) -> Option<&mut crate::StmtDelete> {
503        match self {
504            Self::Delete(val) => Some(val),
505            _ => None,
506        }
507    }
508
509    #[inline]
510    pub fn as_delete_stmt(&self) -> Option<&crate::StmtDelete> {
511        match self {
512            Self::Delete(val) => Some(val),
513            _ => None,
514        }
515    }
516
517    #[inline]
518    pub const fn is_type_alias_stmt(&self) -> bool {
519        matches!(self, Self::TypeAlias(_))
520    }
521
522    #[inline]
523    pub fn type_alias_stmt(self) -> Option<crate::StmtTypeAlias> {
524        match self {
525            Self::TypeAlias(val) => Some(val),
526            _ => None,
527        }
528    }
529
530    #[inline]
531    pub fn expect_type_alias_stmt(self) -> crate::StmtTypeAlias {
532        match self {
533            Self::TypeAlias(val) => val,
534            _ => panic!("called expect on {self:?}"),
535        }
536    }
537
538    #[inline]
539    pub fn as_type_alias_stmt_mut(&mut self) -> Option<&mut crate::StmtTypeAlias> {
540        match self {
541            Self::TypeAlias(val) => Some(val),
542            _ => None,
543        }
544    }
545
546    #[inline]
547    pub fn as_type_alias_stmt(&self) -> Option<&crate::StmtTypeAlias> {
548        match self {
549            Self::TypeAlias(val) => Some(val),
550            _ => None,
551        }
552    }
553
554    #[inline]
555    pub const fn is_assign_stmt(&self) -> bool {
556        matches!(self, Self::Assign(_))
557    }
558
559    #[inline]
560    pub fn assign_stmt(self) -> Option<crate::StmtAssign> {
561        match self {
562            Self::Assign(val) => Some(val),
563            _ => None,
564        }
565    }
566
567    #[inline]
568    pub fn expect_assign_stmt(self) -> crate::StmtAssign {
569        match self {
570            Self::Assign(val) => val,
571            _ => panic!("called expect on {self:?}"),
572        }
573    }
574
575    #[inline]
576    pub fn as_assign_stmt_mut(&mut self) -> Option<&mut crate::StmtAssign> {
577        match self {
578            Self::Assign(val) => Some(val),
579            _ => None,
580        }
581    }
582
583    #[inline]
584    pub fn as_assign_stmt(&self) -> Option<&crate::StmtAssign> {
585        match self {
586            Self::Assign(val) => Some(val),
587            _ => None,
588        }
589    }
590
591    #[inline]
592    pub const fn is_aug_assign_stmt(&self) -> bool {
593        matches!(self, Self::AugAssign(_))
594    }
595
596    #[inline]
597    pub fn aug_assign_stmt(self) -> Option<crate::StmtAugAssign> {
598        match self {
599            Self::AugAssign(val) => Some(val),
600            _ => None,
601        }
602    }
603
604    #[inline]
605    pub fn expect_aug_assign_stmt(self) -> crate::StmtAugAssign {
606        match self {
607            Self::AugAssign(val) => val,
608            _ => panic!("called expect on {self:?}"),
609        }
610    }
611
612    #[inline]
613    pub fn as_aug_assign_stmt_mut(&mut self) -> Option<&mut crate::StmtAugAssign> {
614        match self {
615            Self::AugAssign(val) => Some(val),
616            _ => None,
617        }
618    }
619
620    #[inline]
621    pub fn as_aug_assign_stmt(&self) -> Option<&crate::StmtAugAssign> {
622        match self {
623            Self::AugAssign(val) => Some(val),
624            _ => None,
625        }
626    }
627
628    #[inline]
629    pub const fn is_ann_assign_stmt(&self) -> bool {
630        matches!(self, Self::AnnAssign(_))
631    }
632
633    #[inline]
634    pub fn ann_assign_stmt(self) -> Option<crate::StmtAnnAssign> {
635        match self {
636            Self::AnnAssign(val) => Some(val),
637            _ => None,
638        }
639    }
640
641    #[inline]
642    pub fn expect_ann_assign_stmt(self) -> crate::StmtAnnAssign {
643        match self {
644            Self::AnnAssign(val) => val,
645            _ => panic!("called expect on {self:?}"),
646        }
647    }
648
649    #[inline]
650    pub fn as_ann_assign_stmt_mut(&mut self) -> Option<&mut crate::StmtAnnAssign> {
651        match self {
652            Self::AnnAssign(val) => Some(val),
653            _ => None,
654        }
655    }
656
657    #[inline]
658    pub fn as_ann_assign_stmt(&self) -> Option<&crate::StmtAnnAssign> {
659        match self {
660            Self::AnnAssign(val) => Some(val),
661            _ => None,
662        }
663    }
664
665    #[inline]
666    pub const fn is_for_stmt(&self) -> bool {
667        matches!(self, Self::For(_))
668    }
669
670    #[inline]
671    pub fn for_stmt(self) -> Option<crate::StmtFor> {
672        match self {
673            Self::For(val) => Some(val),
674            _ => None,
675        }
676    }
677
678    #[inline]
679    pub fn expect_for_stmt(self) -> crate::StmtFor {
680        match self {
681            Self::For(val) => val,
682            _ => panic!("called expect on {self:?}"),
683        }
684    }
685
686    #[inline]
687    pub fn as_for_stmt_mut(&mut self) -> Option<&mut crate::StmtFor> {
688        match self {
689            Self::For(val) => Some(val),
690            _ => None,
691        }
692    }
693
694    #[inline]
695    pub fn as_for_stmt(&self) -> Option<&crate::StmtFor> {
696        match self {
697            Self::For(val) => Some(val),
698            _ => None,
699        }
700    }
701
702    #[inline]
703    pub const fn is_while_stmt(&self) -> bool {
704        matches!(self, Self::While(_))
705    }
706
707    #[inline]
708    pub fn while_stmt(self) -> Option<crate::StmtWhile> {
709        match self {
710            Self::While(val) => Some(val),
711            _ => None,
712        }
713    }
714
715    #[inline]
716    pub fn expect_while_stmt(self) -> crate::StmtWhile {
717        match self {
718            Self::While(val) => val,
719            _ => panic!("called expect on {self:?}"),
720        }
721    }
722
723    #[inline]
724    pub fn as_while_stmt_mut(&mut self) -> Option<&mut crate::StmtWhile> {
725        match self {
726            Self::While(val) => Some(val),
727            _ => None,
728        }
729    }
730
731    #[inline]
732    pub fn as_while_stmt(&self) -> Option<&crate::StmtWhile> {
733        match self {
734            Self::While(val) => Some(val),
735            _ => None,
736        }
737    }
738
739    #[inline]
740    pub const fn is_if_stmt(&self) -> bool {
741        matches!(self, Self::If(_))
742    }
743
744    #[inline]
745    pub fn if_stmt(self) -> Option<crate::StmtIf> {
746        match self {
747            Self::If(val) => Some(val),
748            _ => None,
749        }
750    }
751
752    #[inline]
753    pub fn expect_if_stmt(self) -> crate::StmtIf {
754        match self {
755            Self::If(val) => val,
756            _ => panic!("called expect on {self:?}"),
757        }
758    }
759
760    #[inline]
761    pub fn as_if_stmt_mut(&mut self) -> Option<&mut crate::StmtIf> {
762        match self {
763            Self::If(val) => Some(val),
764            _ => None,
765        }
766    }
767
768    #[inline]
769    pub fn as_if_stmt(&self) -> Option<&crate::StmtIf> {
770        match self {
771            Self::If(val) => Some(val),
772            _ => None,
773        }
774    }
775
776    #[inline]
777    pub const fn is_with_stmt(&self) -> bool {
778        matches!(self, Self::With(_))
779    }
780
781    #[inline]
782    pub fn with_stmt(self) -> Option<crate::StmtWith> {
783        match self {
784            Self::With(val) => Some(val),
785            _ => None,
786        }
787    }
788
789    #[inline]
790    pub fn expect_with_stmt(self) -> crate::StmtWith {
791        match self {
792            Self::With(val) => val,
793            _ => panic!("called expect on {self:?}"),
794        }
795    }
796
797    #[inline]
798    pub fn as_with_stmt_mut(&mut self) -> Option<&mut crate::StmtWith> {
799        match self {
800            Self::With(val) => Some(val),
801            _ => None,
802        }
803    }
804
805    #[inline]
806    pub fn as_with_stmt(&self) -> Option<&crate::StmtWith> {
807        match self {
808            Self::With(val) => Some(val),
809            _ => None,
810        }
811    }
812
813    #[inline]
814    pub const fn is_match_stmt(&self) -> bool {
815        matches!(self, Self::Match(_))
816    }
817
818    #[inline]
819    pub fn match_stmt(self) -> Option<crate::StmtMatch> {
820        match self {
821            Self::Match(val) => Some(val),
822            _ => None,
823        }
824    }
825
826    #[inline]
827    pub fn expect_match_stmt(self) -> crate::StmtMatch {
828        match self {
829            Self::Match(val) => val,
830            _ => panic!("called expect on {self:?}"),
831        }
832    }
833
834    #[inline]
835    pub fn as_match_stmt_mut(&mut self) -> Option<&mut crate::StmtMatch> {
836        match self {
837            Self::Match(val) => Some(val),
838            _ => None,
839        }
840    }
841
842    #[inline]
843    pub fn as_match_stmt(&self) -> Option<&crate::StmtMatch> {
844        match self {
845            Self::Match(val) => Some(val),
846            _ => None,
847        }
848    }
849
850    #[inline]
851    pub const fn is_raise_stmt(&self) -> bool {
852        matches!(self, Self::Raise(_))
853    }
854
855    #[inline]
856    pub fn raise_stmt(self) -> Option<crate::StmtRaise> {
857        match self {
858            Self::Raise(val) => Some(val),
859            _ => None,
860        }
861    }
862
863    #[inline]
864    pub fn expect_raise_stmt(self) -> crate::StmtRaise {
865        match self {
866            Self::Raise(val) => val,
867            _ => panic!("called expect on {self:?}"),
868        }
869    }
870
871    #[inline]
872    pub fn as_raise_stmt_mut(&mut self) -> Option<&mut crate::StmtRaise> {
873        match self {
874            Self::Raise(val) => Some(val),
875            _ => None,
876        }
877    }
878
879    #[inline]
880    pub fn as_raise_stmt(&self) -> Option<&crate::StmtRaise> {
881        match self {
882            Self::Raise(val) => Some(val),
883            _ => None,
884        }
885    }
886
887    #[inline]
888    pub const fn is_try_stmt(&self) -> bool {
889        matches!(self, Self::Try(_))
890    }
891
892    #[inline]
893    pub fn try_stmt(self) -> Option<crate::StmtTry> {
894        match self {
895            Self::Try(val) => Some(val),
896            _ => None,
897        }
898    }
899
900    #[inline]
901    pub fn expect_try_stmt(self) -> crate::StmtTry {
902        match self {
903            Self::Try(val) => val,
904            _ => panic!("called expect on {self:?}"),
905        }
906    }
907
908    #[inline]
909    pub fn as_try_stmt_mut(&mut self) -> Option<&mut crate::StmtTry> {
910        match self {
911            Self::Try(val) => Some(val),
912            _ => None,
913        }
914    }
915
916    #[inline]
917    pub fn as_try_stmt(&self) -> Option<&crate::StmtTry> {
918        match self {
919            Self::Try(val) => Some(val),
920            _ => None,
921        }
922    }
923
924    #[inline]
925    pub const fn is_assert_stmt(&self) -> bool {
926        matches!(self, Self::Assert(_))
927    }
928
929    #[inline]
930    pub fn assert_stmt(self) -> Option<crate::StmtAssert> {
931        match self {
932            Self::Assert(val) => Some(val),
933            _ => None,
934        }
935    }
936
937    #[inline]
938    pub fn expect_assert_stmt(self) -> crate::StmtAssert {
939        match self {
940            Self::Assert(val) => val,
941            _ => panic!("called expect on {self:?}"),
942        }
943    }
944
945    #[inline]
946    pub fn as_assert_stmt_mut(&mut self) -> Option<&mut crate::StmtAssert> {
947        match self {
948            Self::Assert(val) => Some(val),
949            _ => None,
950        }
951    }
952
953    #[inline]
954    pub fn as_assert_stmt(&self) -> Option<&crate::StmtAssert> {
955        match self {
956            Self::Assert(val) => Some(val),
957            _ => None,
958        }
959    }
960
961    #[inline]
962    pub const fn is_import_stmt(&self) -> bool {
963        matches!(self, Self::Import(_))
964    }
965
966    #[inline]
967    pub fn import_stmt(self) -> Option<crate::StmtImport> {
968        match self {
969            Self::Import(val) => Some(val),
970            _ => None,
971        }
972    }
973
974    #[inline]
975    pub fn expect_import_stmt(self) -> crate::StmtImport {
976        match self {
977            Self::Import(val) => val,
978            _ => panic!("called expect on {self:?}"),
979        }
980    }
981
982    #[inline]
983    pub fn as_import_stmt_mut(&mut self) -> Option<&mut crate::StmtImport> {
984        match self {
985            Self::Import(val) => Some(val),
986            _ => None,
987        }
988    }
989
990    #[inline]
991    pub fn as_import_stmt(&self) -> Option<&crate::StmtImport> {
992        match self {
993            Self::Import(val) => Some(val),
994            _ => None,
995        }
996    }
997
998    #[inline]
999    pub const fn is_import_from_stmt(&self) -> bool {
1000        matches!(self, Self::ImportFrom(_))
1001    }
1002
1003    #[inline]
1004    pub fn import_from_stmt(self) -> Option<crate::StmtImportFrom> {
1005        match self {
1006            Self::ImportFrom(val) => Some(val),
1007            _ => None,
1008        }
1009    }
1010
1011    #[inline]
1012    pub fn expect_import_from_stmt(self) -> crate::StmtImportFrom {
1013        match self {
1014            Self::ImportFrom(val) => val,
1015            _ => panic!("called expect on {self:?}"),
1016        }
1017    }
1018
1019    #[inline]
1020    pub fn as_import_from_stmt_mut(&mut self) -> Option<&mut crate::StmtImportFrom> {
1021        match self {
1022            Self::ImportFrom(val) => Some(val),
1023            _ => None,
1024        }
1025    }
1026
1027    #[inline]
1028    pub fn as_import_from_stmt(&self) -> Option<&crate::StmtImportFrom> {
1029        match self {
1030            Self::ImportFrom(val) => Some(val),
1031            _ => None,
1032        }
1033    }
1034
1035    #[inline]
1036    pub const fn is_global_stmt(&self) -> bool {
1037        matches!(self, Self::Global(_))
1038    }
1039
1040    #[inline]
1041    pub fn global_stmt(self) -> Option<crate::StmtGlobal> {
1042        match self {
1043            Self::Global(val) => Some(val),
1044            _ => None,
1045        }
1046    }
1047
1048    #[inline]
1049    pub fn expect_global_stmt(self) -> crate::StmtGlobal {
1050        match self {
1051            Self::Global(val) => val,
1052            _ => panic!("called expect on {self:?}"),
1053        }
1054    }
1055
1056    #[inline]
1057    pub fn as_global_stmt_mut(&mut self) -> Option<&mut crate::StmtGlobal> {
1058        match self {
1059            Self::Global(val) => Some(val),
1060            _ => None,
1061        }
1062    }
1063
1064    #[inline]
1065    pub fn as_global_stmt(&self) -> Option<&crate::StmtGlobal> {
1066        match self {
1067            Self::Global(val) => Some(val),
1068            _ => None,
1069        }
1070    }
1071
1072    #[inline]
1073    pub const fn is_nonlocal_stmt(&self) -> bool {
1074        matches!(self, Self::Nonlocal(_))
1075    }
1076
1077    #[inline]
1078    pub fn nonlocal_stmt(self) -> Option<crate::StmtNonlocal> {
1079        match self {
1080            Self::Nonlocal(val) => Some(val),
1081            _ => None,
1082        }
1083    }
1084
1085    #[inline]
1086    pub fn expect_nonlocal_stmt(self) -> crate::StmtNonlocal {
1087        match self {
1088            Self::Nonlocal(val) => val,
1089            _ => panic!("called expect on {self:?}"),
1090        }
1091    }
1092
1093    #[inline]
1094    pub fn as_nonlocal_stmt_mut(&mut self) -> Option<&mut crate::StmtNonlocal> {
1095        match self {
1096            Self::Nonlocal(val) => Some(val),
1097            _ => None,
1098        }
1099    }
1100
1101    #[inline]
1102    pub fn as_nonlocal_stmt(&self) -> Option<&crate::StmtNonlocal> {
1103        match self {
1104            Self::Nonlocal(val) => Some(val),
1105            _ => None,
1106        }
1107    }
1108
1109    #[inline]
1110    pub const fn is_expr_stmt(&self) -> bool {
1111        matches!(self, Self::Expr(_))
1112    }
1113
1114    #[inline]
1115    pub fn expr_stmt(self) -> Option<crate::StmtExpr> {
1116        match self {
1117            Self::Expr(val) => Some(val),
1118            _ => None,
1119        }
1120    }
1121
1122    #[inline]
1123    pub fn expect_expr_stmt(self) -> crate::StmtExpr {
1124        match self {
1125            Self::Expr(val) => val,
1126            _ => panic!("called expect on {self:?}"),
1127        }
1128    }
1129
1130    #[inline]
1131    pub fn as_expr_stmt_mut(&mut self) -> Option<&mut crate::StmtExpr> {
1132        match self {
1133            Self::Expr(val) => Some(val),
1134            _ => None,
1135        }
1136    }
1137
1138    #[inline]
1139    pub fn as_expr_stmt(&self) -> Option<&crate::StmtExpr> {
1140        match self {
1141            Self::Expr(val) => Some(val),
1142            _ => None,
1143        }
1144    }
1145
1146    #[inline]
1147    pub const fn is_pass_stmt(&self) -> bool {
1148        matches!(self, Self::Pass(_))
1149    }
1150
1151    #[inline]
1152    pub fn pass_stmt(self) -> Option<crate::StmtPass> {
1153        match self {
1154            Self::Pass(val) => Some(val),
1155            _ => None,
1156        }
1157    }
1158
1159    #[inline]
1160    pub fn expect_pass_stmt(self) -> crate::StmtPass {
1161        match self {
1162            Self::Pass(val) => val,
1163            _ => panic!("called expect on {self:?}"),
1164        }
1165    }
1166
1167    #[inline]
1168    pub fn as_pass_stmt_mut(&mut self) -> Option<&mut crate::StmtPass> {
1169        match self {
1170            Self::Pass(val) => Some(val),
1171            _ => None,
1172        }
1173    }
1174
1175    #[inline]
1176    pub fn as_pass_stmt(&self) -> Option<&crate::StmtPass> {
1177        match self {
1178            Self::Pass(val) => Some(val),
1179            _ => None,
1180        }
1181    }
1182
1183    #[inline]
1184    pub const fn is_break_stmt(&self) -> bool {
1185        matches!(self, Self::Break(_))
1186    }
1187
1188    #[inline]
1189    pub fn break_stmt(self) -> Option<crate::StmtBreak> {
1190        match self {
1191            Self::Break(val) => Some(val),
1192            _ => None,
1193        }
1194    }
1195
1196    #[inline]
1197    pub fn expect_break_stmt(self) -> crate::StmtBreak {
1198        match self {
1199            Self::Break(val) => val,
1200            _ => panic!("called expect on {self:?}"),
1201        }
1202    }
1203
1204    #[inline]
1205    pub fn as_break_stmt_mut(&mut self) -> Option<&mut crate::StmtBreak> {
1206        match self {
1207            Self::Break(val) => Some(val),
1208            _ => None,
1209        }
1210    }
1211
1212    #[inline]
1213    pub fn as_break_stmt(&self) -> Option<&crate::StmtBreak> {
1214        match self {
1215            Self::Break(val) => Some(val),
1216            _ => None,
1217        }
1218    }
1219
1220    #[inline]
1221    pub const fn is_continue_stmt(&self) -> bool {
1222        matches!(self, Self::Continue(_))
1223    }
1224
1225    #[inline]
1226    pub fn continue_stmt(self) -> Option<crate::StmtContinue> {
1227        match self {
1228            Self::Continue(val) => Some(val),
1229            _ => None,
1230        }
1231    }
1232
1233    #[inline]
1234    pub fn expect_continue_stmt(self) -> crate::StmtContinue {
1235        match self {
1236            Self::Continue(val) => val,
1237            _ => panic!("called expect on {self:?}"),
1238        }
1239    }
1240
1241    #[inline]
1242    pub fn as_continue_stmt_mut(&mut self) -> Option<&mut crate::StmtContinue> {
1243        match self {
1244            Self::Continue(val) => Some(val),
1245            _ => None,
1246        }
1247    }
1248
1249    #[inline]
1250    pub fn as_continue_stmt(&self) -> Option<&crate::StmtContinue> {
1251        match self {
1252            Self::Continue(val) => Some(val),
1253            _ => None,
1254        }
1255    }
1256
1257    #[inline]
1258    pub const fn is_ipy_escape_command_stmt(&self) -> bool {
1259        matches!(self, Self::IpyEscapeCommand(_))
1260    }
1261
1262    #[inline]
1263    pub fn ipy_escape_command_stmt(self) -> Option<crate::StmtIpyEscapeCommand> {
1264        match self {
1265            Self::IpyEscapeCommand(val) => Some(val),
1266            _ => None,
1267        }
1268    }
1269
1270    #[inline]
1271    pub fn expect_ipy_escape_command_stmt(self) -> crate::StmtIpyEscapeCommand {
1272        match self {
1273            Self::IpyEscapeCommand(val) => val,
1274            _ => panic!("called expect on {self:?}"),
1275        }
1276    }
1277
1278    #[inline]
1279    pub fn as_ipy_escape_command_stmt_mut(&mut self) -> Option<&mut crate::StmtIpyEscapeCommand> {
1280        match self {
1281            Self::IpyEscapeCommand(val) => Some(val),
1282            _ => None,
1283        }
1284    }
1285
1286    #[inline]
1287    pub fn as_ipy_escape_command_stmt(&self) -> Option<&crate::StmtIpyEscapeCommand> {
1288        match self {
1289            Self::IpyEscapeCommand(val) => Some(val),
1290            _ => None,
1291        }
1292    }
1293}
1294
1295/// See also [expr](https://docs.python.org/3/library/ast.html#ast.expr)
1296#[derive(Clone, Debug, PartialEq)]
1297#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
1298pub enum Expr {
1299    BoolOp(crate::ExprBoolOp),
1300    Named(crate::ExprNamed),
1301    BinOp(crate::ExprBinOp),
1302    UnaryOp(crate::ExprUnaryOp),
1303    Lambda(crate::ExprLambda),
1304    If(crate::ExprIf),
1305    Dict(crate::ExprDict),
1306    Set(crate::ExprSet),
1307    ListComp(crate::ExprListComp),
1308    SetComp(crate::ExprSetComp),
1309    DictComp(crate::ExprDictComp),
1310    Generator(crate::ExprGenerator),
1311    Await(crate::ExprAwait),
1312    Yield(crate::ExprYield),
1313    YieldFrom(crate::ExprYieldFrom),
1314    Compare(crate::ExprCompare),
1315    Call(crate::ExprCall),
1316    FString(crate::ExprFString),
1317    TString(crate::ExprTString),
1318    StringLiteral(crate::ExprStringLiteral),
1319    BytesLiteral(crate::ExprBytesLiteral),
1320    NumberLiteral(crate::ExprNumberLiteral),
1321    BooleanLiteral(crate::ExprBooleanLiteral),
1322    NoneLiteral(crate::ExprNoneLiteral),
1323    EllipsisLiteral(crate::ExprEllipsisLiteral),
1324    Attribute(crate::ExprAttribute),
1325    Subscript(crate::ExprSubscript),
1326    Starred(crate::ExprStarred),
1327    Name(crate::ExprName),
1328    List(crate::ExprList),
1329    Tuple(crate::ExprTuple),
1330    Slice(crate::ExprSlice),
1331    IpyEscapeCommand(crate::ExprIpyEscapeCommand),
1332}
1333
1334impl From<crate::ExprBoolOp> for Expr {
1335    fn from(node: crate::ExprBoolOp) -> Self {
1336        Self::BoolOp(node)
1337    }
1338}
1339
1340impl From<crate::ExprNamed> for Expr {
1341    fn from(node: crate::ExprNamed) -> Self {
1342        Self::Named(node)
1343    }
1344}
1345
1346impl From<crate::ExprBinOp> for Expr {
1347    fn from(node: crate::ExprBinOp) -> Self {
1348        Self::BinOp(node)
1349    }
1350}
1351
1352impl From<crate::ExprUnaryOp> for Expr {
1353    fn from(node: crate::ExprUnaryOp) -> Self {
1354        Self::UnaryOp(node)
1355    }
1356}
1357
1358impl From<crate::ExprLambda> for Expr {
1359    fn from(node: crate::ExprLambda) -> Self {
1360        Self::Lambda(node)
1361    }
1362}
1363
1364impl From<crate::ExprIf> for Expr {
1365    fn from(node: crate::ExprIf) -> Self {
1366        Self::If(node)
1367    }
1368}
1369
1370impl From<crate::ExprDict> for Expr {
1371    fn from(node: crate::ExprDict) -> Self {
1372        Self::Dict(node)
1373    }
1374}
1375
1376impl From<crate::ExprSet> for Expr {
1377    fn from(node: crate::ExprSet) -> Self {
1378        Self::Set(node)
1379    }
1380}
1381
1382impl From<crate::ExprListComp> for Expr {
1383    fn from(node: crate::ExprListComp) -> Self {
1384        Self::ListComp(node)
1385    }
1386}
1387
1388impl From<crate::ExprSetComp> for Expr {
1389    fn from(node: crate::ExprSetComp) -> Self {
1390        Self::SetComp(node)
1391    }
1392}
1393
1394impl From<crate::ExprDictComp> for Expr {
1395    fn from(node: crate::ExprDictComp) -> Self {
1396        Self::DictComp(node)
1397    }
1398}
1399
1400impl From<crate::ExprGenerator> for Expr {
1401    fn from(node: crate::ExprGenerator) -> Self {
1402        Self::Generator(node)
1403    }
1404}
1405
1406impl From<crate::ExprAwait> for Expr {
1407    fn from(node: crate::ExprAwait) -> Self {
1408        Self::Await(node)
1409    }
1410}
1411
1412impl From<crate::ExprYield> for Expr {
1413    fn from(node: crate::ExprYield) -> Self {
1414        Self::Yield(node)
1415    }
1416}
1417
1418impl From<crate::ExprYieldFrom> for Expr {
1419    fn from(node: crate::ExprYieldFrom) -> Self {
1420        Self::YieldFrom(node)
1421    }
1422}
1423
1424impl From<crate::ExprCompare> for Expr {
1425    fn from(node: crate::ExprCompare) -> Self {
1426        Self::Compare(node)
1427    }
1428}
1429
1430impl From<crate::ExprCall> for Expr {
1431    fn from(node: crate::ExprCall) -> Self {
1432        Self::Call(node)
1433    }
1434}
1435
1436impl From<crate::ExprFString> for Expr {
1437    fn from(node: crate::ExprFString) -> Self {
1438        Self::FString(node)
1439    }
1440}
1441
1442impl From<crate::ExprTString> for Expr {
1443    fn from(node: crate::ExprTString) -> Self {
1444        Self::TString(node)
1445    }
1446}
1447
1448impl From<crate::ExprStringLiteral> for Expr {
1449    fn from(node: crate::ExprStringLiteral) -> Self {
1450        Self::StringLiteral(node)
1451    }
1452}
1453
1454impl From<crate::ExprBytesLiteral> for Expr {
1455    fn from(node: crate::ExprBytesLiteral) -> Self {
1456        Self::BytesLiteral(node)
1457    }
1458}
1459
1460impl From<crate::ExprNumberLiteral> for Expr {
1461    fn from(node: crate::ExprNumberLiteral) -> Self {
1462        Self::NumberLiteral(node)
1463    }
1464}
1465
1466impl From<crate::ExprBooleanLiteral> for Expr {
1467    fn from(node: crate::ExprBooleanLiteral) -> Self {
1468        Self::BooleanLiteral(node)
1469    }
1470}
1471
1472impl From<crate::ExprNoneLiteral> for Expr {
1473    fn from(node: crate::ExprNoneLiteral) -> Self {
1474        Self::NoneLiteral(node)
1475    }
1476}
1477
1478impl From<crate::ExprEllipsisLiteral> for Expr {
1479    fn from(node: crate::ExprEllipsisLiteral) -> Self {
1480        Self::EllipsisLiteral(node)
1481    }
1482}
1483
1484impl From<crate::ExprAttribute> for Expr {
1485    fn from(node: crate::ExprAttribute) -> Self {
1486        Self::Attribute(node)
1487    }
1488}
1489
1490impl From<crate::ExprSubscript> for Expr {
1491    fn from(node: crate::ExprSubscript) -> Self {
1492        Self::Subscript(node)
1493    }
1494}
1495
1496impl From<crate::ExprStarred> for Expr {
1497    fn from(node: crate::ExprStarred) -> Self {
1498        Self::Starred(node)
1499    }
1500}
1501
1502impl From<crate::ExprName> for Expr {
1503    fn from(node: crate::ExprName) -> Self {
1504        Self::Name(node)
1505    }
1506}
1507
1508impl From<crate::ExprList> for Expr {
1509    fn from(node: crate::ExprList) -> Self {
1510        Self::List(node)
1511    }
1512}
1513
1514impl From<crate::ExprTuple> for Expr {
1515    fn from(node: crate::ExprTuple) -> Self {
1516        Self::Tuple(node)
1517    }
1518}
1519
1520impl From<crate::ExprSlice> for Expr {
1521    fn from(node: crate::ExprSlice) -> Self {
1522        Self::Slice(node)
1523    }
1524}
1525
1526impl From<crate::ExprIpyEscapeCommand> for Expr {
1527    fn from(node: crate::ExprIpyEscapeCommand) -> Self {
1528        Self::IpyEscapeCommand(node)
1529    }
1530}
1531
1532impl ruff_text_size::Ranged for Expr {
1533    fn range(&self) -> ruff_text_size::TextRange {
1534        match self {
1535            Self::BoolOp(node) => node.range(),
1536            Self::Named(node) => node.range(),
1537            Self::BinOp(node) => node.range(),
1538            Self::UnaryOp(node) => node.range(),
1539            Self::Lambda(node) => node.range(),
1540            Self::If(node) => node.range(),
1541            Self::Dict(node) => node.range(),
1542            Self::Set(node) => node.range(),
1543            Self::ListComp(node) => node.range(),
1544            Self::SetComp(node) => node.range(),
1545            Self::DictComp(node) => node.range(),
1546            Self::Generator(node) => node.range(),
1547            Self::Await(node) => node.range(),
1548            Self::Yield(node) => node.range(),
1549            Self::YieldFrom(node) => node.range(),
1550            Self::Compare(node) => node.range(),
1551            Self::Call(node) => node.range(),
1552            Self::FString(node) => node.range(),
1553            Self::TString(node) => node.range(),
1554            Self::StringLiteral(node) => node.range(),
1555            Self::BytesLiteral(node) => node.range(),
1556            Self::NumberLiteral(node) => node.range(),
1557            Self::BooleanLiteral(node) => node.range(),
1558            Self::NoneLiteral(node) => node.range(),
1559            Self::EllipsisLiteral(node) => node.range(),
1560            Self::Attribute(node) => node.range(),
1561            Self::Subscript(node) => node.range(),
1562            Self::Starred(node) => node.range(),
1563            Self::Name(node) => node.range(),
1564            Self::List(node) => node.range(),
1565            Self::Tuple(node) => node.range(),
1566            Self::Slice(node) => node.range(),
1567            Self::IpyEscapeCommand(node) => node.range(),
1568        }
1569    }
1570}
1571
1572impl crate::HasNodeIndex for Expr {
1573    fn node_index(&self) -> &crate::AtomicNodeIndex {
1574        match self {
1575            Self::BoolOp(node) => node.node_index(),
1576            Self::Named(node) => node.node_index(),
1577            Self::BinOp(node) => node.node_index(),
1578            Self::UnaryOp(node) => node.node_index(),
1579            Self::Lambda(node) => node.node_index(),
1580            Self::If(node) => node.node_index(),
1581            Self::Dict(node) => node.node_index(),
1582            Self::Set(node) => node.node_index(),
1583            Self::ListComp(node) => node.node_index(),
1584            Self::SetComp(node) => node.node_index(),
1585            Self::DictComp(node) => node.node_index(),
1586            Self::Generator(node) => node.node_index(),
1587            Self::Await(node) => node.node_index(),
1588            Self::Yield(node) => node.node_index(),
1589            Self::YieldFrom(node) => node.node_index(),
1590            Self::Compare(node) => node.node_index(),
1591            Self::Call(node) => node.node_index(),
1592            Self::FString(node) => node.node_index(),
1593            Self::TString(node) => node.node_index(),
1594            Self::StringLiteral(node) => node.node_index(),
1595            Self::BytesLiteral(node) => node.node_index(),
1596            Self::NumberLiteral(node) => node.node_index(),
1597            Self::BooleanLiteral(node) => node.node_index(),
1598            Self::NoneLiteral(node) => node.node_index(),
1599            Self::EllipsisLiteral(node) => node.node_index(),
1600            Self::Attribute(node) => node.node_index(),
1601            Self::Subscript(node) => node.node_index(),
1602            Self::Starred(node) => node.node_index(),
1603            Self::Name(node) => node.node_index(),
1604            Self::List(node) => node.node_index(),
1605            Self::Tuple(node) => node.node_index(),
1606            Self::Slice(node) => node.node_index(),
1607            Self::IpyEscapeCommand(node) => node.node_index(),
1608        }
1609    }
1610}
1611
1612#[allow(dead_code, clippy::match_wildcard_for_single_variants)]
1613impl Expr {
1614    #[inline]
1615    pub const fn is_bool_op_expr(&self) -> bool {
1616        matches!(self, Self::BoolOp(_))
1617    }
1618
1619    #[inline]
1620    pub fn bool_op_expr(self) -> Option<crate::ExprBoolOp> {
1621        match self {
1622            Self::BoolOp(val) => Some(val),
1623            _ => None,
1624        }
1625    }
1626
1627    #[inline]
1628    pub fn expect_bool_op_expr(self) -> crate::ExprBoolOp {
1629        match self {
1630            Self::BoolOp(val) => val,
1631            _ => panic!("called expect on {self:?}"),
1632        }
1633    }
1634
1635    #[inline]
1636    pub fn as_bool_op_expr_mut(&mut self) -> Option<&mut crate::ExprBoolOp> {
1637        match self {
1638            Self::BoolOp(val) => Some(val),
1639            _ => None,
1640        }
1641    }
1642
1643    #[inline]
1644    pub fn as_bool_op_expr(&self) -> Option<&crate::ExprBoolOp> {
1645        match self {
1646            Self::BoolOp(val) => Some(val),
1647            _ => None,
1648        }
1649    }
1650
1651    #[inline]
1652    pub const fn is_named_expr(&self) -> bool {
1653        matches!(self, Self::Named(_))
1654    }
1655
1656    #[inline]
1657    pub fn named_expr(self) -> Option<crate::ExprNamed> {
1658        match self {
1659            Self::Named(val) => Some(val),
1660            _ => None,
1661        }
1662    }
1663
1664    #[inline]
1665    pub fn expect_named_expr(self) -> crate::ExprNamed {
1666        match self {
1667            Self::Named(val) => val,
1668            _ => panic!("called expect on {self:?}"),
1669        }
1670    }
1671
1672    #[inline]
1673    pub fn as_named_expr_mut(&mut self) -> Option<&mut crate::ExprNamed> {
1674        match self {
1675            Self::Named(val) => Some(val),
1676            _ => None,
1677        }
1678    }
1679
1680    #[inline]
1681    pub fn as_named_expr(&self) -> Option<&crate::ExprNamed> {
1682        match self {
1683            Self::Named(val) => Some(val),
1684            _ => None,
1685        }
1686    }
1687
1688    #[inline]
1689    pub const fn is_bin_op_expr(&self) -> bool {
1690        matches!(self, Self::BinOp(_))
1691    }
1692
1693    #[inline]
1694    pub fn bin_op_expr(self) -> Option<crate::ExprBinOp> {
1695        match self {
1696            Self::BinOp(val) => Some(val),
1697            _ => None,
1698        }
1699    }
1700
1701    #[inline]
1702    pub fn expect_bin_op_expr(self) -> crate::ExprBinOp {
1703        match self {
1704            Self::BinOp(val) => val,
1705            _ => panic!("called expect on {self:?}"),
1706        }
1707    }
1708
1709    #[inline]
1710    pub fn as_bin_op_expr_mut(&mut self) -> Option<&mut crate::ExprBinOp> {
1711        match self {
1712            Self::BinOp(val) => Some(val),
1713            _ => None,
1714        }
1715    }
1716
1717    #[inline]
1718    pub fn as_bin_op_expr(&self) -> Option<&crate::ExprBinOp> {
1719        match self {
1720            Self::BinOp(val) => Some(val),
1721            _ => None,
1722        }
1723    }
1724
1725    #[inline]
1726    pub const fn is_unary_op_expr(&self) -> bool {
1727        matches!(self, Self::UnaryOp(_))
1728    }
1729
1730    #[inline]
1731    pub fn unary_op_expr(self) -> Option<crate::ExprUnaryOp> {
1732        match self {
1733            Self::UnaryOp(val) => Some(val),
1734            _ => None,
1735        }
1736    }
1737
1738    #[inline]
1739    pub fn expect_unary_op_expr(self) -> crate::ExprUnaryOp {
1740        match self {
1741            Self::UnaryOp(val) => val,
1742            _ => panic!("called expect on {self:?}"),
1743        }
1744    }
1745
1746    #[inline]
1747    pub fn as_unary_op_expr_mut(&mut self) -> Option<&mut crate::ExprUnaryOp> {
1748        match self {
1749            Self::UnaryOp(val) => Some(val),
1750            _ => None,
1751        }
1752    }
1753
1754    #[inline]
1755    pub fn as_unary_op_expr(&self) -> Option<&crate::ExprUnaryOp> {
1756        match self {
1757            Self::UnaryOp(val) => Some(val),
1758            _ => None,
1759        }
1760    }
1761
1762    #[inline]
1763    pub const fn is_lambda_expr(&self) -> bool {
1764        matches!(self, Self::Lambda(_))
1765    }
1766
1767    #[inline]
1768    pub fn lambda_expr(self) -> Option<crate::ExprLambda> {
1769        match self {
1770            Self::Lambda(val) => Some(val),
1771            _ => None,
1772        }
1773    }
1774
1775    #[inline]
1776    pub fn expect_lambda_expr(self) -> crate::ExprLambda {
1777        match self {
1778            Self::Lambda(val) => val,
1779            _ => panic!("called expect on {self:?}"),
1780        }
1781    }
1782
1783    #[inline]
1784    pub fn as_lambda_expr_mut(&mut self) -> Option<&mut crate::ExprLambda> {
1785        match self {
1786            Self::Lambda(val) => Some(val),
1787            _ => None,
1788        }
1789    }
1790
1791    #[inline]
1792    pub fn as_lambda_expr(&self) -> Option<&crate::ExprLambda> {
1793        match self {
1794            Self::Lambda(val) => Some(val),
1795            _ => None,
1796        }
1797    }
1798
1799    #[inline]
1800    pub const fn is_if_expr(&self) -> bool {
1801        matches!(self, Self::If(_))
1802    }
1803
1804    #[inline]
1805    pub fn if_expr(self) -> Option<crate::ExprIf> {
1806        match self {
1807            Self::If(val) => Some(val),
1808            _ => None,
1809        }
1810    }
1811
1812    #[inline]
1813    pub fn expect_if_expr(self) -> crate::ExprIf {
1814        match self {
1815            Self::If(val) => val,
1816            _ => panic!("called expect on {self:?}"),
1817        }
1818    }
1819
1820    #[inline]
1821    pub fn as_if_expr_mut(&mut self) -> Option<&mut crate::ExprIf> {
1822        match self {
1823            Self::If(val) => Some(val),
1824            _ => None,
1825        }
1826    }
1827
1828    #[inline]
1829    pub fn as_if_expr(&self) -> Option<&crate::ExprIf> {
1830        match self {
1831            Self::If(val) => Some(val),
1832            _ => None,
1833        }
1834    }
1835
1836    #[inline]
1837    pub const fn is_dict_expr(&self) -> bool {
1838        matches!(self, Self::Dict(_))
1839    }
1840
1841    #[inline]
1842    pub fn dict_expr(self) -> Option<crate::ExprDict> {
1843        match self {
1844            Self::Dict(val) => Some(val),
1845            _ => None,
1846        }
1847    }
1848
1849    #[inline]
1850    pub fn expect_dict_expr(self) -> crate::ExprDict {
1851        match self {
1852            Self::Dict(val) => val,
1853            _ => panic!("called expect on {self:?}"),
1854        }
1855    }
1856
1857    #[inline]
1858    pub fn as_dict_expr_mut(&mut self) -> Option<&mut crate::ExprDict> {
1859        match self {
1860            Self::Dict(val) => Some(val),
1861            _ => None,
1862        }
1863    }
1864
1865    #[inline]
1866    pub fn as_dict_expr(&self) -> Option<&crate::ExprDict> {
1867        match self {
1868            Self::Dict(val) => Some(val),
1869            _ => None,
1870        }
1871    }
1872
1873    #[inline]
1874    pub const fn is_set_expr(&self) -> bool {
1875        matches!(self, Self::Set(_))
1876    }
1877
1878    #[inline]
1879    pub fn set_expr(self) -> Option<crate::ExprSet> {
1880        match self {
1881            Self::Set(val) => Some(val),
1882            _ => None,
1883        }
1884    }
1885
1886    #[inline]
1887    pub fn expect_set_expr(self) -> crate::ExprSet {
1888        match self {
1889            Self::Set(val) => val,
1890            _ => panic!("called expect on {self:?}"),
1891        }
1892    }
1893
1894    #[inline]
1895    pub fn as_set_expr_mut(&mut self) -> Option<&mut crate::ExprSet> {
1896        match self {
1897            Self::Set(val) => Some(val),
1898            _ => None,
1899        }
1900    }
1901
1902    #[inline]
1903    pub fn as_set_expr(&self) -> Option<&crate::ExprSet> {
1904        match self {
1905            Self::Set(val) => Some(val),
1906            _ => None,
1907        }
1908    }
1909
1910    #[inline]
1911    pub const fn is_list_comp_expr(&self) -> bool {
1912        matches!(self, Self::ListComp(_))
1913    }
1914
1915    #[inline]
1916    pub fn list_comp_expr(self) -> Option<crate::ExprListComp> {
1917        match self {
1918            Self::ListComp(val) => Some(val),
1919            _ => None,
1920        }
1921    }
1922
1923    #[inline]
1924    pub fn expect_list_comp_expr(self) -> crate::ExprListComp {
1925        match self {
1926            Self::ListComp(val) => val,
1927            _ => panic!("called expect on {self:?}"),
1928        }
1929    }
1930
1931    #[inline]
1932    pub fn as_list_comp_expr_mut(&mut self) -> Option<&mut crate::ExprListComp> {
1933        match self {
1934            Self::ListComp(val) => Some(val),
1935            _ => None,
1936        }
1937    }
1938
1939    #[inline]
1940    pub fn as_list_comp_expr(&self) -> Option<&crate::ExprListComp> {
1941        match self {
1942            Self::ListComp(val) => Some(val),
1943            _ => None,
1944        }
1945    }
1946
1947    #[inline]
1948    pub const fn is_set_comp_expr(&self) -> bool {
1949        matches!(self, Self::SetComp(_))
1950    }
1951
1952    #[inline]
1953    pub fn set_comp_expr(self) -> Option<crate::ExprSetComp> {
1954        match self {
1955            Self::SetComp(val) => Some(val),
1956            _ => None,
1957        }
1958    }
1959
1960    #[inline]
1961    pub fn expect_set_comp_expr(self) -> crate::ExprSetComp {
1962        match self {
1963            Self::SetComp(val) => val,
1964            _ => panic!("called expect on {self:?}"),
1965        }
1966    }
1967
1968    #[inline]
1969    pub fn as_set_comp_expr_mut(&mut self) -> Option<&mut crate::ExprSetComp> {
1970        match self {
1971            Self::SetComp(val) => Some(val),
1972            _ => None,
1973        }
1974    }
1975
1976    #[inline]
1977    pub fn as_set_comp_expr(&self) -> Option<&crate::ExprSetComp> {
1978        match self {
1979            Self::SetComp(val) => Some(val),
1980            _ => None,
1981        }
1982    }
1983
1984    #[inline]
1985    pub const fn is_dict_comp_expr(&self) -> bool {
1986        matches!(self, Self::DictComp(_))
1987    }
1988
1989    #[inline]
1990    pub fn dict_comp_expr(self) -> Option<crate::ExprDictComp> {
1991        match self {
1992            Self::DictComp(val) => Some(val),
1993            _ => None,
1994        }
1995    }
1996
1997    #[inline]
1998    pub fn expect_dict_comp_expr(self) -> crate::ExprDictComp {
1999        match self {
2000            Self::DictComp(val) => val,
2001            _ => panic!("called expect on {self:?}"),
2002        }
2003    }
2004
2005    #[inline]
2006    pub fn as_dict_comp_expr_mut(&mut self) -> Option<&mut crate::ExprDictComp> {
2007        match self {
2008            Self::DictComp(val) => Some(val),
2009            _ => None,
2010        }
2011    }
2012
2013    #[inline]
2014    pub fn as_dict_comp_expr(&self) -> Option<&crate::ExprDictComp> {
2015        match self {
2016            Self::DictComp(val) => Some(val),
2017            _ => None,
2018        }
2019    }
2020
2021    #[inline]
2022    pub const fn is_generator_expr(&self) -> bool {
2023        matches!(self, Self::Generator(_))
2024    }
2025
2026    #[inline]
2027    pub fn generator_expr(self) -> Option<crate::ExprGenerator> {
2028        match self {
2029            Self::Generator(val) => Some(val),
2030            _ => None,
2031        }
2032    }
2033
2034    #[inline]
2035    pub fn expect_generator_expr(self) -> crate::ExprGenerator {
2036        match self {
2037            Self::Generator(val) => val,
2038            _ => panic!("called expect on {self:?}"),
2039        }
2040    }
2041
2042    #[inline]
2043    pub fn as_generator_expr_mut(&mut self) -> Option<&mut crate::ExprGenerator> {
2044        match self {
2045            Self::Generator(val) => Some(val),
2046            _ => None,
2047        }
2048    }
2049
2050    #[inline]
2051    pub fn as_generator_expr(&self) -> Option<&crate::ExprGenerator> {
2052        match self {
2053            Self::Generator(val) => Some(val),
2054            _ => None,
2055        }
2056    }
2057
2058    #[inline]
2059    pub const fn is_await_expr(&self) -> bool {
2060        matches!(self, Self::Await(_))
2061    }
2062
2063    #[inline]
2064    pub fn await_expr(self) -> Option<crate::ExprAwait> {
2065        match self {
2066            Self::Await(val) => Some(val),
2067            _ => None,
2068        }
2069    }
2070
2071    #[inline]
2072    pub fn expect_await_expr(self) -> crate::ExprAwait {
2073        match self {
2074            Self::Await(val) => val,
2075            _ => panic!("called expect on {self:?}"),
2076        }
2077    }
2078
2079    #[inline]
2080    pub fn as_await_expr_mut(&mut self) -> Option<&mut crate::ExprAwait> {
2081        match self {
2082            Self::Await(val) => Some(val),
2083            _ => None,
2084        }
2085    }
2086
2087    #[inline]
2088    pub fn as_await_expr(&self) -> Option<&crate::ExprAwait> {
2089        match self {
2090            Self::Await(val) => Some(val),
2091            _ => None,
2092        }
2093    }
2094
2095    #[inline]
2096    pub const fn is_yield_expr(&self) -> bool {
2097        matches!(self, Self::Yield(_))
2098    }
2099
2100    #[inline]
2101    pub fn yield_expr(self) -> Option<crate::ExprYield> {
2102        match self {
2103            Self::Yield(val) => Some(val),
2104            _ => None,
2105        }
2106    }
2107
2108    #[inline]
2109    pub fn expect_yield_expr(self) -> crate::ExprYield {
2110        match self {
2111            Self::Yield(val) => val,
2112            _ => panic!("called expect on {self:?}"),
2113        }
2114    }
2115
2116    #[inline]
2117    pub fn as_yield_expr_mut(&mut self) -> Option<&mut crate::ExprYield> {
2118        match self {
2119            Self::Yield(val) => Some(val),
2120            _ => None,
2121        }
2122    }
2123
2124    #[inline]
2125    pub fn as_yield_expr(&self) -> Option<&crate::ExprYield> {
2126        match self {
2127            Self::Yield(val) => Some(val),
2128            _ => None,
2129        }
2130    }
2131
2132    #[inline]
2133    pub const fn is_yield_from_expr(&self) -> bool {
2134        matches!(self, Self::YieldFrom(_))
2135    }
2136
2137    #[inline]
2138    pub fn yield_from_expr(self) -> Option<crate::ExprYieldFrom> {
2139        match self {
2140            Self::YieldFrom(val) => Some(val),
2141            _ => None,
2142        }
2143    }
2144
2145    #[inline]
2146    pub fn expect_yield_from_expr(self) -> crate::ExprYieldFrom {
2147        match self {
2148            Self::YieldFrom(val) => val,
2149            _ => panic!("called expect on {self:?}"),
2150        }
2151    }
2152
2153    #[inline]
2154    pub fn as_yield_from_expr_mut(&mut self) -> Option<&mut crate::ExprYieldFrom> {
2155        match self {
2156            Self::YieldFrom(val) => Some(val),
2157            _ => None,
2158        }
2159    }
2160
2161    #[inline]
2162    pub fn as_yield_from_expr(&self) -> Option<&crate::ExprYieldFrom> {
2163        match self {
2164            Self::YieldFrom(val) => Some(val),
2165            _ => None,
2166        }
2167    }
2168
2169    #[inline]
2170    pub const fn is_compare_expr(&self) -> bool {
2171        matches!(self, Self::Compare(_))
2172    }
2173
2174    #[inline]
2175    pub fn compare_expr(self) -> Option<crate::ExprCompare> {
2176        match self {
2177            Self::Compare(val) => Some(val),
2178            _ => None,
2179        }
2180    }
2181
2182    #[inline]
2183    pub fn expect_compare_expr(self) -> crate::ExprCompare {
2184        match self {
2185            Self::Compare(val) => val,
2186            _ => panic!("called expect on {self:?}"),
2187        }
2188    }
2189
2190    #[inline]
2191    pub fn as_compare_expr_mut(&mut self) -> Option<&mut crate::ExprCompare> {
2192        match self {
2193            Self::Compare(val) => Some(val),
2194            _ => None,
2195        }
2196    }
2197
2198    #[inline]
2199    pub fn as_compare_expr(&self) -> Option<&crate::ExprCompare> {
2200        match self {
2201            Self::Compare(val) => Some(val),
2202            _ => None,
2203        }
2204    }
2205
2206    #[inline]
2207    pub const fn is_call_expr(&self) -> bool {
2208        matches!(self, Self::Call(_))
2209    }
2210
2211    #[inline]
2212    pub fn call_expr(self) -> Option<crate::ExprCall> {
2213        match self {
2214            Self::Call(val) => Some(val),
2215            _ => None,
2216        }
2217    }
2218
2219    #[inline]
2220    pub fn expect_call_expr(self) -> crate::ExprCall {
2221        match self {
2222            Self::Call(val) => val,
2223            _ => panic!("called expect on {self:?}"),
2224        }
2225    }
2226
2227    #[inline]
2228    pub fn as_call_expr_mut(&mut self) -> Option<&mut crate::ExprCall> {
2229        match self {
2230            Self::Call(val) => Some(val),
2231            _ => None,
2232        }
2233    }
2234
2235    #[inline]
2236    pub fn as_call_expr(&self) -> Option<&crate::ExprCall> {
2237        match self {
2238            Self::Call(val) => Some(val),
2239            _ => None,
2240        }
2241    }
2242
2243    #[inline]
2244    pub const fn is_f_string_expr(&self) -> bool {
2245        matches!(self, Self::FString(_))
2246    }
2247
2248    #[inline]
2249    pub fn f_string_expr(self) -> Option<crate::ExprFString> {
2250        match self {
2251            Self::FString(val) => Some(val),
2252            _ => None,
2253        }
2254    }
2255
2256    #[inline]
2257    pub fn expect_f_string_expr(self) -> crate::ExprFString {
2258        match self {
2259            Self::FString(val) => val,
2260            _ => panic!("called expect on {self:?}"),
2261        }
2262    }
2263
2264    #[inline]
2265    pub fn as_f_string_expr_mut(&mut self) -> Option<&mut crate::ExprFString> {
2266        match self {
2267            Self::FString(val) => Some(val),
2268            _ => None,
2269        }
2270    }
2271
2272    #[inline]
2273    pub fn as_f_string_expr(&self) -> Option<&crate::ExprFString> {
2274        match self {
2275            Self::FString(val) => Some(val),
2276            _ => None,
2277        }
2278    }
2279
2280    #[inline]
2281    pub const fn is_t_string_expr(&self) -> bool {
2282        matches!(self, Self::TString(_))
2283    }
2284
2285    #[inline]
2286    pub fn t_string_expr(self) -> Option<crate::ExprTString> {
2287        match self {
2288            Self::TString(val) => Some(val),
2289            _ => None,
2290        }
2291    }
2292
2293    #[inline]
2294    pub fn expect_t_string_expr(self) -> crate::ExprTString {
2295        match self {
2296            Self::TString(val) => val,
2297            _ => panic!("called expect on {self:?}"),
2298        }
2299    }
2300
2301    #[inline]
2302    pub fn as_t_string_expr_mut(&mut self) -> Option<&mut crate::ExprTString> {
2303        match self {
2304            Self::TString(val) => Some(val),
2305            _ => None,
2306        }
2307    }
2308
2309    #[inline]
2310    pub fn as_t_string_expr(&self) -> Option<&crate::ExprTString> {
2311        match self {
2312            Self::TString(val) => Some(val),
2313            _ => None,
2314        }
2315    }
2316
2317    #[inline]
2318    pub const fn is_string_literal_expr(&self) -> bool {
2319        matches!(self, Self::StringLiteral(_))
2320    }
2321
2322    #[inline]
2323    pub fn string_literal_expr(self) -> Option<crate::ExprStringLiteral> {
2324        match self {
2325            Self::StringLiteral(val) => Some(val),
2326            _ => None,
2327        }
2328    }
2329
2330    #[inline]
2331    pub fn expect_string_literal_expr(self) -> crate::ExprStringLiteral {
2332        match self {
2333            Self::StringLiteral(val) => val,
2334            _ => panic!("called expect on {self:?}"),
2335        }
2336    }
2337
2338    #[inline]
2339    pub fn as_string_literal_expr_mut(&mut self) -> Option<&mut crate::ExprStringLiteral> {
2340        match self {
2341            Self::StringLiteral(val) => Some(val),
2342            _ => None,
2343        }
2344    }
2345
2346    #[inline]
2347    pub fn as_string_literal_expr(&self) -> Option<&crate::ExprStringLiteral> {
2348        match self {
2349            Self::StringLiteral(val) => Some(val),
2350            _ => None,
2351        }
2352    }
2353
2354    #[inline]
2355    pub const fn is_bytes_literal_expr(&self) -> bool {
2356        matches!(self, Self::BytesLiteral(_))
2357    }
2358
2359    #[inline]
2360    pub fn bytes_literal_expr(self) -> Option<crate::ExprBytesLiteral> {
2361        match self {
2362            Self::BytesLiteral(val) => Some(val),
2363            _ => None,
2364        }
2365    }
2366
2367    #[inline]
2368    pub fn expect_bytes_literal_expr(self) -> crate::ExprBytesLiteral {
2369        match self {
2370            Self::BytesLiteral(val) => val,
2371            _ => panic!("called expect on {self:?}"),
2372        }
2373    }
2374
2375    #[inline]
2376    pub fn as_bytes_literal_expr_mut(&mut self) -> Option<&mut crate::ExprBytesLiteral> {
2377        match self {
2378            Self::BytesLiteral(val) => Some(val),
2379            _ => None,
2380        }
2381    }
2382
2383    #[inline]
2384    pub fn as_bytes_literal_expr(&self) -> Option<&crate::ExprBytesLiteral> {
2385        match self {
2386            Self::BytesLiteral(val) => Some(val),
2387            _ => None,
2388        }
2389    }
2390
2391    #[inline]
2392    pub const fn is_number_literal_expr(&self) -> bool {
2393        matches!(self, Self::NumberLiteral(_))
2394    }
2395
2396    #[inline]
2397    pub fn number_literal_expr(self) -> Option<crate::ExprNumberLiteral> {
2398        match self {
2399            Self::NumberLiteral(val) => Some(val),
2400            _ => None,
2401        }
2402    }
2403
2404    #[inline]
2405    pub fn expect_number_literal_expr(self) -> crate::ExprNumberLiteral {
2406        match self {
2407            Self::NumberLiteral(val) => val,
2408            _ => panic!("called expect on {self:?}"),
2409        }
2410    }
2411
2412    #[inline]
2413    pub fn as_number_literal_expr_mut(&mut self) -> Option<&mut crate::ExprNumberLiteral> {
2414        match self {
2415            Self::NumberLiteral(val) => Some(val),
2416            _ => None,
2417        }
2418    }
2419
2420    #[inline]
2421    pub fn as_number_literal_expr(&self) -> Option<&crate::ExprNumberLiteral> {
2422        match self {
2423            Self::NumberLiteral(val) => Some(val),
2424            _ => None,
2425        }
2426    }
2427
2428    #[inline]
2429    pub const fn is_boolean_literal_expr(&self) -> bool {
2430        matches!(self, Self::BooleanLiteral(_))
2431    }
2432
2433    #[inline]
2434    pub fn boolean_literal_expr(self) -> Option<crate::ExprBooleanLiteral> {
2435        match self {
2436            Self::BooleanLiteral(val) => Some(val),
2437            _ => None,
2438        }
2439    }
2440
2441    #[inline]
2442    pub fn expect_boolean_literal_expr(self) -> crate::ExprBooleanLiteral {
2443        match self {
2444            Self::BooleanLiteral(val) => val,
2445            _ => panic!("called expect on {self:?}"),
2446        }
2447    }
2448
2449    #[inline]
2450    pub fn as_boolean_literal_expr_mut(&mut self) -> Option<&mut crate::ExprBooleanLiteral> {
2451        match self {
2452            Self::BooleanLiteral(val) => Some(val),
2453            _ => None,
2454        }
2455    }
2456
2457    #[inline]
2458    pub fn as_boolean_literal_expr(&self) -> Option<&crate::ExprBooleanLiteral> {
2459        match self {
2460            Self::BooleanLiteral(val) => Some(val),
2461            _ => None,
2462        }
2463    }
2464
2465    #[inline]
2466    pub const fn is_none_literal_expr(&self) -> bool {
2467        matches!(self, Self::NoneLiteral(_))
2468    }
2469
2470    #[inline]
2471    pub fn none_literal_expr(self) -> Option<crate::ExprNoneLiteral> {
2472        match self {
2473            Self::NoneLiteral(val) => Some(val),
2474            _ => None,
2475        }
2476    }
2477
2478    #[inline]
2479    pub fn expect_none_literal_expr(self) -> crate::ExprNoneLiteral {
2480        match self {
2481            Self::NoneLiteral(val) => val,
2482            _ => panic!("called expect on {self:?}"),
2483        }
2484    }
2485
2486    #[inline]
2487    pub fn as_none_literal_expr_mut(&mut self) -> Option<&mut crate::ExprNoneLiteral> {
2488        match self {
2489            Self::NoneLiteral(val) => Some(val),
2490            _ => None,
2491        }
2492    }
2493
2494    #[inline]
2495    pub fn as_none_literal_expr(&self) -> Option<&crate::ExprNoneLiteral> {
2496        match self {
2497            Self::NoneLiteral(val) => Some(val),
2498            _ => None,
2499        }
2500    }
2501
2502    #[inline]
2503    pub const fn is_ellipsis_literal_expr(&self) -> bool {
2504        matches!(self, Self::EllipsisLiteral(_))
2505    }
2506
2507    #[inline]
2508    pub fn ellipsis_literal_expr(self) -> Option<crate::ExprEllipsisLiteral> {
2509        match self {
2510            Self::EllipsisLiteral(val) => Some(val),
2511            _ => None,
2512        }
2513    }
2514
2515    #[inline]
2516    pub fn expect_ellipsis_literal_expr(self) -> crate::ExprEllipsisLiteral {
2517        match self {
2518            Self::EllipsisLiteral(val) => val,
2519            _ => panic!("called expect on {self:?}"),
2520        }
2521    }
2522
2523    #[inline]
2524    pub fn as_ellipsis_literal_expr_mut(&mut self) -> Option<&mut crate::ExprEllipsisLiteral> {
2525        match self {
2526            Self::EllipsisLiteral(val) => Some(val),
2527            _ => None,
2528        }
2529    }
2530
2531    #[inline]
2532    pub fn as_ellipsis_literal_expr(&self) -> Option<&crate::ExprEllipsisLiteral> {
2533        match self {
2534            Self::EllipsisLiteral(val) => Some(val),
2535            _ => None,
2536        }
2537    }
2538
2539    #[inline]
2540    pub const fn is_attribute_expr(&self) -> bool {
2541        matches!(self, Self::Attribute(_))
2542    }
2543
2544    #[inline]
2545    pub fn attribute_expr(self) -> Option<crate::ExprAttribute> {
2546        match self {
2547            Self::Attribute(val) => Some(val),
2548            _ => None,
2549        }
2550    }
2551
2552    #[inline]
2553    pub fn expect_attribute_expr(self) -> crate::ExprAttribute {
2554        match self {
2555            Self::Attribute(val) => val,
2556            _ => panic!("called expect on {self:?}"),
2557        }
2558    }
2559
2560    #[inline]
2561    pub fn as_attribute_expr_mut(&mut self) -> Option<&mut crate::ExprAttribute> {
2562        match self {
2563            Self::Attribute(val) => Some(val),
2564            _ => None,
2565        }
2566    }
2567
2568    #[inline]
2569    pub fn as_attribute_expr(&self) -> Option<&crate::ExprAttribute> {
2570        match self {
2571            Self::Attribute(val) => Some(val),
2572            _ => None,
2573        }
2574    }
2575
2576    #[inline]
2577    pub const fn is_subscript_expr(&self) -> bool {
2578        matches!(self, Self::Subscript(_))
2579    }
2580
2581    #[inline]
2582    pub fn subscript_expr(self) -> Option<crate::ExprSubscript> {
2583        match self {
2584            Self::Subscript(val) => Some(val),
2585            _ => None,
2586        }
2587    }
2588
2589    #[inline]
2590    pub fn expect_subscript_expr(self) -> crate::ExprSubscript {
2591        match self {
2592            Self::Subscript(val) => val,
2593            _ => panic!("called expect on {self:?}"),
2594        }
2595    }
2596
2597    #[inline]
2598    pub fn as_subscript_expr_mut(&mut self) -> Option<&mut crate::ExprSubscript> {
2599        match self {
2600            Self::Subscript(val) => Some(val),
2601            _ => None,
2602        }
2603    }
2604
2605    #[inline]
2606    pub fn as_subscript_expr(&self) -> Option<&crate::ExprSubscript> {
2607        match self {
2608            Self::Subscript(val) => Some(val),
2609            _ => None,
2610        }
2611    }
2612
2613    #[inline]
2614    pub const fn is_starred_expr(&self) -> bool {
2615        matches!(self, Self::Starred(_))
2616    }
2617
2618    #[inline]
2619    pub fn starred_expr(self) -> Option<crate::ExprStarred> {
2620        match self {
2621            Self::Starred(val) => Some(val),
2622            _ => None,
2623        }
2624    }
2625
2626    #[inline]
2627    pub fn expect_starred_expr(self) -> crate::ExprStarred {
2628        match self {
2629            Self::Starred(val) => val,
2630            _ => panic!("called expect on {self:?}"),
2631        }
2632    }
2633
2634    #[inline]
2635    pub fn as_starred_expr_mut(&mut self) -> Option<&mut crate::ExprStarred> {
2636        match self {
2637            Self::Starred(val) => Some(val),
2638            _ => None,
2639        }
2640    }
2641
2642    #[inline]
2643    pub fn as_starred_expr(&self) -> Option<&crate::ExprStarred> {
2644        match self {
2645            Self::Starred(val) => Some(val),
2646            _ => None,
2647        }
2648    }
2649
2650    #[inline]
2651    pub const fn is_name_expr(&self) -> bool {
2652        matches!(self, Self::Name(_))
2653    }
2654
2655    #[inline]
2656    pub fn name_expr(self) -> Option<crate::ExprName> {
2657        match self {
2658            Self::Name(val) => Some(val),
2659            _ => None,
2660        }
2661    }
2662
2663    #[inline]
2664    pub fn expect_name_expr(self) -> crate::ExprName {
2665        match self {
2666            Self::Name(val) => val,
2667            _ => panic!("called expect on {self:?}"),
2668        }
2669    }
2670
2671    #[inline]
2672    pub fn as_name_expr_mut(&mut self) -> Option<&mut crate::ExprName> {
2673        match self {
2674            Self::Name(val) => Some(val),
2675            _ => None,
2676        }
2677    }
2678
2679    #[inline]
2680    pub fn as_name_expr(&self) -> Option<&crate::ExprName> {
2681        match self {
2682            Self::Name(val) => Some(val),
2683            _ => None,
2684        }
2685    }
2686
2687    #[inline]
2688    pub const fn is_list_expr(&self) -> bool {
2689        matches!(self, Self::List(_))
2690    }
2691
2692    #[inline]
2693    pub fn list_expr(self) -> Option<crate::ExprList> {
2694        match self {
2695            Self::List(val) => Some(val),
2696            _ => None,
2697        }
2698    }
2699
2700    #[inline]
2701    pub fn expect_list_expr(self) -> crate::ExprList {
2702        match self {
2703            Self::List(val) => val,
2704            _ => panic!("called expect on {self:?}"),
2705        }
2706    }
2707
2708    #[inline]
2709    pub fn as_list_expr_mut(&mut self) -> Option<&mut crate::ExprList> {
2710        match self {
2711            Self::List(val) => Some(val),
2712            _ => None,
2713        }
2714    }
2715
2716    #[inline]
2717    pub fn as_list_expr(&self) -> Option<&crate::ExprList> {
2718        match self {
2719            Self::List(val) => Some(val),
2720            _ => None,
2721        }
2722    }
2723
2724    #[inline]
2725    pub const fn is_tuple_expr(&self) -> bool {
2726        matches!(self, Self::Tuple(_))
2727    }
2728
2729    #[inline]
2730    pub fn tuple_expr(self) -> Option<crate::ExprTuple> {
2731        match self {
2732            Self::Tuple(val) => Some(val),
2733            _ => None,
2734        }
2735    }
2736
2737    #[inline]
2738    pub fn expect_tuple_expr(self) -> crate::ExprTuple {
2739        match self {
2740            Self::Tuple(val) => val,
2741            _ => panic!("called expect on {self:?}"),
2742        }
2743    }
2744
2745    #[inline]
2746    pub fn as_tuple_expr_mut(&mut self) -> Option<&mut crate::ExprTuple> {
2747        match self {
2748            Self::Tuple(val) => Some(val),
2749            _ => None,
2750        }
2751    }
2752
2753    #[inline]
2754    pub fn as_tuple_expr(&self) -> Option<&crate::ExprTuple> {
2755        match self {
2756            Self::Tuple(val) => Some(val),
2757            _ => None,
2758        }
2759    }
2760
2761    #[inline]
2762    pub const fn is_slice_expr(&self) -> bool {
2763        matches!(self, Self::Slice(_))
2764    }
2765
2766    #[inline]
2767    pub fn slice_expr(self) -> Option<crate::ExprSlice> {
2768        match self {
2769            Self::Slice(val) => Some(val),
2770            _ => None,
2771        }
2772    }
2773
2774    #[inline]
2775    pub fn expect_slice_expr(self) -> crate::ExprSlice {
2776        match self {
2777            Self::Slice(val) => val,
2778            _ => panic!("called expect on {self:?}"),
2779        }
2780    }
2781
2782    #[inline]
2783    pub fn as_slice_expr_mut(&mut self) -> Option<&mut crate::ExprSlice> {
2784        match self {
2785            Self::Slice(val) => Some(val),
2786            _ => None,
2787        }
2788    }
2789
2790    #[inline]
2791    pub fn as_slice_expr(&self) -> Option<&crate::ExprSlice> {
2792        match self {
2793            Self::Slice(val) => Some(val),
2794            _ => None,
2795        }
2796    }
2797
2798    #[inline]
2799    pub const fn is_ipy_escape_command_expr(&self) -> bool {
2800        matches!(self, Self::IpyEscapeCommand(_))
2801    }
2802
2803    #[inline]
2804    pub fn ipy_escape_command_expr(self) -> Option<crate::ExprIpyEscapeCommand> {
2805        match self {
2806            Self::IpyEscapeCommand(val) => Some(val),
2807            _ => None,
2808        }
2809    }
2810
2811    #[inline]
2812    pub fn expect_ipy_escape_command_expr(self) -> crate::ExprIpyEscapeCommand {
2813        match self {
2814            Self::IpyEscapeCommand(val) => val,
2815            _ => panic!("called expect on {self:?}"),
2816        }
2817    }
2818
2819    #[inline]
2820    pub fn as_ipy_escape_command_expr_mut(&mut self) -> Option<&mut crate::ExprIpyEscapeCommand> {
2821        match self {
2822            Self::IpyEscapeCommand(val) => Some(val),
2823            _ => None,
2824        }
2825    }
2826
2827    #[inline]
2828    pub fn as_ipy_escape_command_expr(&self) -> Option<&crate::ExprIpyEscapeCommand> {
2829        match self {
2830            Self::IpyEscapeCommand(val) => Some(val),
2831            _ => None,
2832        }
2833    }
2834}
2835
2836/// See also [excepthandler](https://docs.python.org/3/library/ast.html#ast.excepthandler)
2837#[derive(Clone, Debug, PartialEq)]
2838#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
2839pub enum ExceptHandler {
2840    ExceptHandler(crate::ExceptHandlerExceptHandler),
2841}
2842
2843impl From<crate::ExceptHandlerExceptHandler> for ExceptHandler {
2844    fn from(node: crate::ExceptHandlerExceptHandler) -> Self {
2845        Self::ExceptHandler(node)
2846    }
2847}
2848
2849impl ruff_text_size::Ranged for ExceptHandler {
2850    fn range(&self) -> ruff_text_size::TextRange {
2851        match self {
2852            Self::ExceptHandler(node) => node.range(),
2853        }
2854    }
2855}
2856
2857impl crate::HasNodeIndex for ExceptHandler {
2858    fn node_index(&self) -> &crate::AtomicNodeIndex {
2859        match self {
2860            Self::ExceptHandler(node) => node.node_index(),
2861        }
2862    }
2863}
2864
2865#[allow(dead_code, clippy::match_wildcard_for_single_variants)]
2866impl ExceptHandler {
2867    #[inline]
2868    pub const fn is_except_handler(&self) -> bool {
2869        matches!(self, Self::ExceptHandler(_))
2870    }
2871
2872    #[inline]
2873    pub fn except_handler(self) -> Option<crate::ExceptHandlerExceptHandler> {
2874        match self {
2875            Self::ExceptHandler(val) => Some(val),
2876        }
2877    }
2878
2879    #[inline]
2880    pub fn expect_except_handler(self) -> crate::ExceptHandlerExceptHandler {
2881        match self {
2882            Self::ExceptHandler(val) => val,
2883        }
2884    }
2885
2886    #[inline]
2887    pub fn as_except_handler_mut(&mut self) -> Option<&mut crate::ExceptHandlerExceptHandler> {
2888        match self {
2889            Self::ExceptHandler(val) => Some(val),
2890        }
2891    }
2892
2893    #[inline]
2894    pub fn as_except_handler(&self) -> Option<&crate::ExceptHandlerExceptHandler> {
2895        match self {
2896            Self::ExceptHandler(val) => Some(val),
2897        }
2898    }
2899}
2900
2901#[derive(Clone, Debug, PartialEq)]
2902#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
2903pub enum InterpolatedStringElement {
2904    Interpolation(crate::InterpolatedElement),
2905    Literal(crate::InterpolatedStringLiteralElement),
2906}
2907
2908impl From<crate::InterpolatedElement> for InterpolatedStringElement {
2909    fn from(node: crate::InterpolatedElement) -> Self {
2910        Self::Interpolation(node)
2911    }
2912}
2913
2914impl From<crate::InterpolatedStringLiteralElement> for InterpolatedStringElement {
2915    fn from(node: crate::InterpolatedStringLiteralElement) -> Self {
2916        Self::Literal(node)
2917    }
2918}
2919
2920impl ruff_text_size::Ranged for InterpolatedStringElement {
2921    fn range(&self) -> ruff_text_size::TextRange {
2922        match self {
2923            Self::Interpolation(node) => node.range(),
2924            Self::Literal(node) => node.range(),
2925        }
2926    }
2927}
2928
2929impl crate::HasNodeIndex for InterpolatedStringElement {
2930    fn node_index(&self) -> &crate::AtomicNodeIndex {
2931        match self {
2932            Self::Interpolation(node) => node.node_index(),
2933            Self::Literal(node) => node.node_index(),
2934        }
2935    }
2936}
2937
2938#[allow(dead_code, clippy::match_wildcard_for_single_variants)]
2939impl InterpolatedStringElement {
2940    #[inline]
2941    pub const fn is_interpolation(&self) -> bool {
2942        matches!(self, Self::Interpolation(_))
2943    }
2944
2945    #[inline]
2946    pub fn interpolation(self) -> Option<crate::InterpolatedElement> {
2947        match self {
2948            Self::Interpolation(val) => Some(val),
2949            _ => None,
2950        }
2951    }
2952
2953    #[inline]
2954    pub fn expect_interpolation(self) -> crate::InterpolatedElement {
2955        match self {
2956            Self::Interpolation(val) => val,
2957            _ => panic!("called expect on {self:?}"),
2958        }
2959    }
2960
2961    #[inline]
2962    pub fn as_interpolation_mut(&mut self) -> Option<&mut crate::InterpolatedElement> {
2963        match self {
2964            Self::Interpolation(val) => Some(val),
2965            _ => None,
2966        }
2967    }
2968
2969    #[inline]
2970    pub fn as_interpolation(&self) -> Option<&crate::InterpolatedElement> {
2971        match self {
2972            Self::Interpolation(val) => Some(val),
2973            _ => None,
2974        }
2975    }
2976
2977    #[inline]
2978    pub const fn is_literal(&self) -> bool {
2979        matches!(self, Self::Literal(_))
2980    }
2981
2982    #[inline]
2983    pub fn literal(self) -> Option<crate::InterpolatedStringLiteralElement> {
2984        match self {
2985            Self::Literal(val) => Some(val),
2986            _ => None,
2987        }
2988    }
2989
2990    #[inline]
2991    pub fn expect_literal(self) -> crate::InterpolatedStringLiteralElement {
2992        match self {
2993            Self::Literal(val) => val,
2994            _ => panic!("called expect on {self:?}"),
2995        }
2996    }
2997
2998    #[inline]
2999    pub fn as_literal_mut(&mut self) -> Option<&mut crate::InterpolatedStringLiteralElement> {
3000        match self {
3001            Self::Literal(val) => Some(val),
3002            _ => None,
3003        }
3004    }
3005
3006    #[inline]
3007    pub fn as_literal(&self) -> Option<&crate::InterpolatedStringLiteralElement> {
3008        match self {
3009            Self::Literal(val) => Some(val),
3010            _ => None,
3011        }
3012    }
3013}
3014
3015/// See also [pattern](https://docs.python.org/3/library/ast.html#ast.pattern)
3016#[derive(Clone, Debug, PartialEq)]
3017#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
3018pub enum Pattern {
3019    MatchValue(crate::PatternMatchValue),
3020    MatchSingleton(crate::PatternMatchSingleton),
3021    MatchSequence(crate::PatternMatchSequence),
3022    MatchMapping(crate::PatternMatchMapping),
3023    MatchClass(crate::PatternMatchClass),
3024    MatchStar(crate::PatternMatchStar),
3025    MatchAs(crate::PatternMatchAs),
3026    MatchOr(crate::PatternMatchOr),
3027}
3028
3029impl From<crate::PatternMatchValue> for Pattern {
3030    fn from(node: crate::PatternMatchValue) -> Self {
3031        Self::MatchValue(node)
3032    }
3033}
3034
3035impl From<crate::PatternMatchSingleton> for Pattern {
3036    fn from(node: crate::PatternMatchSingleton) -> Self {
3037        Self::MatchSingleton(node)
3038    }
3039}
3040
3041impl From<crate::PatternMatchSequence> for Pattern {
3042    fn from(node: crate::PatternMatchSequence) -> Self {
3043        Self::MatchSequence(node)
3044    }
3045}
3046
3047impl From<crate::PatternMatchMapping> for Pattern {
3048    fn from(node: crate::PatternMatchMapping) -> Self {
3049        Self::MatchMapping(node)
3050    }
3051}
3052
3053impl From<crate::PatternMatchClass> for Pattern {
3054    fn from(node: crate::PatternMatchClass) -> Self {
3055        Self::MatchClass(node)
3056    }
3057}
3058
3059impl From<crate::PatternMatchStar> for Pattern {
3060    fn from(node: crate::PatternMatchStar) -> Self {
3061        Self::MatchStar(node)
3062    }
3063}
3064
3065impl From<crate::PatternMatchAs> for Pattern {
3066    fn from(node: crate::PatternMatchAs) -> Self {
3067        Self::MatchAs(node)
3068    }
3069}
3070
3071impl From<crate::PatternMatchOr> for Pattern {
3072    fn from(node: crate::PatternMatchOr) -> Self {
3073        Self::MatchOr(node)
3074    }
3075}
3076
3077impl ruff_text_size::Ranged for Pattern {
3078    fn range(&self) -> ruff_text_size::TextRange {
3079        match self {
3080            Self::MatchValue(node) => node.range(),
3081            Self::MatchSingleton(node) => node.range(),
3082            Self::MatchSequence(node) => node.range(),
3083            Self::MatchMapping(node) => node.range(),
3084            Self::MatchClass(node) => node.range(),
3085            Self::MatchStar(node) => node.range(),
3086            Self::MatchAs(node) => node.range(),
3087            Self::MatchOr(node) => node.range(),
3088        }
3089    }
3090}
3091
3092impl crate::HasNodeIndex for Pattern {
3093    fn node_index(&self) -> &crate::AtomicNodeIndex {
3094        match self {
3095            Self::MatchValue(node) => node.node_index(),
3096            Self::MatchSingleton(node) => node.node_index(),
3097            Self::MatchSequence(node) => node.node_index(),
3098            Self::MatchMapping(node) => node.node_index(),
3099            Self::MatchClass(node) => node.node_index(),
3100            Self::MatchStar(node) => node.node_index(),
3101            Self::MatchAs(node) => node.node_index(),
3102            Self::MatchOr(node) => node.node_index(),
3103        }
3104    }
3105}
3106
3107#[allow(dead_code, clippy::match_wildcard_for_single_variants)]
3108impl Pattern {
3109    #[inline]
3110    pub const fn is_match_value(&self) -> bool {
3111        matches!(self, Self::MatchValue(_))
3112    }
3113
3114    #[inline]
3115    pub fn match_value(self) -> Option<crate::PatternMatchValue> {
3116        match self {
3117            Self::MatchValue(val) => Some(val),
3118            _ => None,
3119        }
3120    }
3121
3122    #[inline]
3123    pub fn expect_match_value(self) -> crate::PatternMatchValue {
3124        match self {
3125            Self::MatchValue(val) => val,
3126            _ => panic!("called expect on {self:?}"),
3127        }
3128    }
3129
3130    #[inline]
3131    pub fn as_match_value_mut(&mut self) -> Option<&mut crate::PatternMatchValue> {
3132        match self {
3133            Self::MatchValue(val) => Some(val),
3134            _ => None,
3135        }
3136    }
3137
3138    #[inline]
3139    pub fn as_match_value(&self) -> Option<&crate::PatternMatchValue> {
3140        match self {
3141            Self::MatchValue(val) => Some(val),
3142            _ => None,
3143        }
3144    }
3145
3146    #[inline]
3147    pub const fn is_match_singleton(&self) -> bool {
3148        matches!(self, Self::MatchSingleton(_))
3149    }
3150
3151    #[inline]
3152    pub fn match_singleton(self) -> Option<crate::PatternMatchSingleton> {
3153        match self {
3154            Self::MatchSingleton(val) => Some(val),
3155            _ => None,
3156        }
3157    }
3158
3159    #[inline]
3160    pub fn expect_match_singleton(self) -> crate::PatternMatchSingleton {
3161        match self {
3162            Self::MatchSingleton(val) => val,
3163            _ => panic!("called expect on {self:?}"),
3164        }
3165    }
3166
3167    #[inline]
3168    pub fn as_match_singleton_mut(&mut self) -> Option<&mut crate::PatternMatchSingleton> {
3169        match self {
3170            Self::MatchSingleton(val) => Some(val),
3171            _ => None,
3172        }
3173    }
3174
3175    #[inline]
3176    pub fn as_match_singleton(&self) -> Option<&crate::PatternMatchSingleton> {
3177        match self {
3178            Self::MatchSingleton(val) => Some(val),
3179            _ => None,
3180        }
3181    }
3182
3183    #[inline]
3184    pub const fn is_match_sequence(&self) -> bool {
3185        matches!(self, Self::MatchSequence(_))
3186    }
3187
3188    #[inline]
3189    pub fn match_sequence(self) -> Option<crate::PatternMatchSequence> {
3190        match self {
3191            Self::MatchSequence(val) => Some(val),
3192            _ => None,
3193        }
3194    }
3195
3196    #[inline]
3197    pub fn expect_match_sequence(self) -> crate::PatternMatchSequence {
3198        match self {
3199            Self::MatchSequence(val) => val,
3200            _ => panic!("called expect on {self:?}"),
3201        }
3202    }
3203
3204    #[inline]
3205    pub fn as_match_sequence_mut(&mut self) -> Option<&mut crate::PatternMatchSequence> {
3206        match self {
3207            Self::MatchSequence(val) => Some(val),
3208            _ => None,
3209        }
3210    }
3211
3212    #[inline]
3213    pub fn as_match_sequence(&self) -> Option<&crate::PatternMatchSequence> {
3214        match self {
3215            Self::MatchSequence(val) => Some(val),
3216            _ => None,
3217        }
3218    }
3219
3220    #[inline]
3221    pub const fn is_match_mapping(&self) -> bool {
3222        matches!(self, Self::MatchMapping(_))
3223    }
3224
3225    #[inline]
3226    pub fn match_mapping(self) -> Option<crate::PatternMatchMapping> {
3227        match self {
3228            Self::MatchMapping(val) => Some(val),
3229            _ => None,
3230        }
3231    }
3232
3233    #[inline]
3234    pub fn expect_match_mapping(self) -> crate::PatternMatchMapping {
3235        match self {
3236            Self::MatchMapping(val) => val,
3237            _ => panic!("called expect on {self:?}"),
3238        }
3239    }
3240
3241    #[inline]
3242    pub fn as_match_mapping_mut(&mut self) -> Option<&mut crate::PatternMatchMapping> {
3243        match self {
3244            Self::MatchMapping(val) => Some(val),
3245            _ => None,
3246        }
3247    }
3248
3249    #[inline]
3250    pub fn as_match_mapping(&self) -> Option<&crate::PatternMatchMapping> {
3251        match self {
3252            Self::MatchMapping(val) => Some(val),
3253            _ => None,
3254        }
3255    }
3256
3257    #[inline]
3258    pub const fn is_match_class(&self) -> bool {
3259        matches!(self, Self::MatchClass(_))
3260    }
3261
3262    #[inline]
3263    pub fn match_class(self) -> Option<crate::PatternMatchClass> {
3264        match self {
3265            Self::MatchClass(val) => Some(val),
3266            _ => None,
3267        }
3268    }
3269
3270    #[inline]
3271    pub fn expect_match_class(self) -> crate::PatternMatchClass {
3272        match self {
3273            Self::MatchClass(val) => val,
3274            _ => panic!("called expect on {self:?}"),
3275        }
3276    }
3277
3278    #[inline]
3279    pub fn as_match_class_mut(&mut self) -> Option<&mut crate::PatternMatchClass> {
3280        match self {
3281            Self::MatchClass(val) => Some(val),
3282            _ => None,
3283        }
3284    }
3285
3286    #[inline]
3287    pub fn as_match_class(&self) -> Option<&crate::PatternMatchClass> {
3288        match self {
3289            Self::MatchClass(val) => Some(val),
3290            _ => None,
3291        }
3292    }
3293
3294    #[inline]
3295    pub const fn is_match_star(&self) -> bool {
3296        matches!(self, Self::MatchStar(_))
3297    }
3298
3299    #[inline]
3300    pub fn match_star(self) -> Option<crate::PatternMatchStar> {
3301        match self {
3302            Self::MatchStar(val) => Some(val),
3303            _ => None,
3304        }
3305    }
3306
3307    #[inline]
3308    pub fn expect_match_star(self) -> crate::PatternMatchStar {
3309        match self {
3310            Self::MatchStar(val) => val,
3311            _ => panic!("called expect on {self:?}"),
3312        }
3313    }
3314
3315    #[inline]
3316    pub fn as_match_star_mut(&mut self) -> Option<&mut crate::PatternMatchStar> {
3317        match self {
3318            Self::MatchStar(val) => Some(val),
3319            _ => None,
3320        }
3321    }
3322
3323    #[inline]
3324    pub fn as_match_star(&self) -> Option<&crate::PatternMatchStar> {
3325        match self {
3326            Self::MatchStar(val) => Some(val),
3327            _ => None,
3328        }
3329    }
3330
3331    #[inline]
3332    pub const fn is_match_as(&self) -> bool {
3333        matches!(self, Self::MatchAs(_))
3334    }
3335
3336    #[inline]
3337    pub fn match_as(self) -> Option<crate::PatternMatchAs> {
3338        match self {
3339            Self::MatchAs(val) => Some(val),
3340            _ => None,
3341        }
3342    }
3343
3344    #[inline]
3345    pub fn expect_match_as(self) -> crate::PatternMatchAs {
3346        match self {
3347            Self::MatchAs(val) => val,
3348            _ => panic!("called expect on {self:?}"),
3349        }
3350    }
3351
3352    #[inline]
3353    pub fn as_match_as_mut(&mut self) -> Option<&mut crate::PatternMatchAs> {
3354        match self {
3355            Self::MatchAs(val) => Some(val),
3356            _ => None,
3357        }
3358    }
3359
3360    #[inline]
3361    pub fn as_match_as(&self) -> Option<&crate::PatternMatchAs> {
3362        match self {
3363            Self::MatchAs(val) => Some(val),
3364            _ => None,
3365        }
3366    }
3367
3368    #[inline]
3369    pub const fn is_match_or(&self) -> bool {
3370        matches!(self, Self::MatchOr(_))
3371    }
3372
3373    #[inline]
3374    pub fn match_or(self) -> Option<crate::PatternMatchOr> {
3375        match self {
3376            Self::MatchOr(val) => Some(val),
3377            _ => None,
3378        }
3379    }
3380
3381    #[inline]
3382    pub fn expect_match_or(self) -> crate::PatternMatchOr {
3383        match self {
3384            Self::MatchOr(val) => val,
3385            _ => panic!("called expect on {self:?}"),
3386        }
3387    }
3388
3389    #[inline]
3390    pub fn as_match_or_mut(&mut self) -> Option<&mut crate::PatternMatchOr> {
3391        match self {
3392            Self::MatchOr(val) => Some(val),
3393            _ => None,
3394        }
3395    }
3396
3397    #[inline]
3398    pub fn as_match_or(&self) -> Option<&crate::PatternMatchOr> {
3399        match self {
3400            Self::MatchOr(val) => Some(val),
3401            _ => None,
3402        }
3403    }
3404}
3405
3406/// See also [type_param](https://docs.python.org/3/library/ast.html#ast.type_param)
3407#[derive(Clone, Debug, PartialEq)]
3408#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
3409pub enum TypeParam {
3410    TypeVar(crate::TypeParamTypeVar),
3411    TypeVarTuple(crate::TypeParamTypeVarTuple),
3412    ParamSpec(crate::TypeParamParamSpec),
3413}
3414
3415impl From<crate::TypeParamTypeVar> for TypeParam {
3416    fn from(node: crate::TypeParamTypeVar) -> Self {
3417        Self::TypeVar(node)
3418    }
3419}
3420
3421impl From<crate::TypeParamTypeVarTuple> for TypeParam {
3422    fn from(node: crate::TypeParamTypeVarTuple) -> Self {
3423        Self::TypeVarTuple(node)
3424    }
3425}
3426
3427impl From<crate::TypeParamParamSpec> for TypeParam {
3428    fn from(node: crate::TypeParamParamSpec) -> Self {
3429        Self::ParamSpec(node)
3430    }
3431}
3432
3433impl ruff_text_size::Ranged for TypeParam {
3434    fn range(&self) -> ruff_text_size::TextRange {
3435        match self {
3436            Self::TypeVar(node) => node.range(),
3437            Self::TypeVarTuple(node) => node.range(),
3438            Self::ParamSpec(node) => node.range(),
3439        }
3440    }
3441}
3442
3443impl crate::HasNodeIndex for TypeParam {
3444    fn node_index(&self) -> &crate::AtomicNodeIndex {
3445        match self {
3446            Self::TypeVar(node) => node.node_index(),
3447            Self::TypeVarTuple(node) => node.node_index(),
3448            Self::ParamSpec(node) => node.node_index(),
3449        }
3450    }
3451}
3452
3453#[allow(dead_code, clippy::match_wildcard_for_single_variants)]
3454impl TypeParam {
3455    #[inline]
3456    pub const fn is_type_var(&self) -> bool {
3457        matches!(self, Self::TypeVar(_))
3458    }
3459
3460    #[inline]
3461    pub fn type_var(self) -> Option<crate::TypeParamTypeVar> {
3462        match self {
3463            Self::TypeVar(val) => Some(val),
3464            _ => None,
3465        }
3466    }
3467
3468    #[inline]
3469    pub fn expect_type_var(self) -> crate::TypeParamTypeVar {
3470        match self {
3471            Self::TypeVar(val) => val,
3472            _ => panic!("called expect on {self:?}"),
3473        }
3474    }
3475
3476    #[inline]
3477    pub fn as_type_var_mut(&mut self) -> Option<&mut crate::TypeParamTypeVar> {
3478        match self {
3479            Self::TypeVar(val) => Some(val),
3480            _ => None,
3481        }
3482    }
3483
3484    #[inline]
3485    pub fn as_type_var(&self) -> Option<&crate::TypeParamTypeVar> {
3486        match self {
3487            Self::TypeVar(val) => Some(val),
3488            _ => None,
3489        }
3490    }
3491
3492    #[inline]
3493    pub const fn is_type_var_tuple(&self) -> bool {
3494        matches!(self, Self::TypeVarTuple(_))
3495    }
3496
3497    #[inline]
3498    pub fn type_var_tuple(self) -> Option<crate::TypeParamTypeVarTuple> {
3499        match self {
3500            Self::TypeVarTuple(val) => Some(val),
3501            _ => None,
3502        }
3503    }
3504
3505    #[inline]
3506    pub fn expect_type_var_tuple(self) -> crate::TypeParamTypeVarTuple {
3507        match self {
3508            Self::TypeVarTuple(val) => val,
3509            _ => panic!("called expect on {self:?}"),
3510        }
3511    }
3512
3513    #[inline]
3514    pub fn as_type_var_tuple_mut(&mut self) -> Option<&mut crate::TypeParamTypeVarTuple> {
3515        match self {
3516            Self::TypeVarTuple(val) => Some(val),
3517            _ => None,
3518        }
3519    }
3520
3521    #[inline]
3522    pub fn as_type_var_tuple(&self) -> Option<&crate::TypeParamTypeVarTuple> {
3523        match self {
3524            Self::TypeVarTuple(val) => Some(val),
3525            _ => None,
3526        }
3527    }
3528
3529    #[inline]
3530    pub const fn is_param_spec(&self) -> bool {
3531        matches!(self, Self::ParamSpec(_))
3532    }
3533
3534    #[inline]
3535    pub fn param_spec(self) -> Option<crate::TypeParamParamSpec> {
3536        match self {
3537            Self::ParamSpec(val) => Some(val),
3538            _ => None,
3539        }
3540    }
3541
3542    #[inline]
3543    pub fn expect_param_spec(self) -> crate::TypeParamParamSpec {
3544        match self {
3545            Self::ParamSpec(val) => val,
3546            _ => panic!("called expect on {self:?}"),
3547        }
3548    }
3549
3550    #[inline]
3551    pub fn as_param_spec_mut(&mut self) -> Option<&mut crate::TypeParamParamSpec> {
3552        match self {
3553            Self::ParamSpec(val) => Some(val),
3554            _ => None,
3555        }
3556    }
3557
3558    #[inline]
3559    pub fn as_param_spec(&self) -> Option<&crate::TypeParamParamSpec> {
3560        match self {
3561            Self::ParamSpec(val) => Some(val),
3562            _ => None,
3563        }
3564    }
3565}
3566
3567impl ruff_text_size::Ranged for crate::ModModule {
3568    fn range(&self) -> ruff_text_size::TextRange {
3569        self.range
3570    }
3571}
3572
3573impl ruff_text_size::Ranged for crate::ModExpression {
3574    fn range(&self) -> ruff_text_size::TextRange {
3575        self.range
3576    }
3577}
3578
3579impl ruff_text_size::Ranged for crate::StmtFunctionDef {
3580    fn range(&self) -> ruff_text_size::TextRange {
3581        self.range
3582    }
3583}
3584
3585impl ruff_text_size::Ranged for crate::StmtClassDef {
3586    fn range(&self) -> ruff_text_size::TextRange {
3587        self.range
3588    }
3589}
3590
3591impl ruff_text_size::Ranged for crate::StmtReturn {
3592    fn range(&self) -> ruff_text_size::TextRange {
3593        self.range
3594    }
3595}
3596
3597impl ruff_text_size::Ranged for crate::StmtDelete {
3598    fn range(&self) -> ruff_text_size::TextRange {
3599        self.range
3600    }
3601}
3602
3603impl ruff_text_size::Ranged for crate::StmtTypeAlias {
3604    fn range(&self) -> ruff_text_size::TextRange {
3605        self.range
3606    }
3607}
3608
3609impl ruff_text_size::Ranged for crate::StmtAssign {
3610    fn range(&self) -> ruff_text_size::TextRange {
3611        self.range
3612    }
3613}
3614
3615impl ruff_text_size::Ranged for crate::StmtAugAssign {
3616    fn range(&self) -> ruff_text_size::TextRange {
3617        self.range
3618    }
3619}
3620
3621impl ruff_text_size::Ranged for crate::StmtAnnAssign {
3622    fn range(&self) -> ruff_text_size::TextRange {
3623        self.range
3624    }
3625}
3626
3627impl ruff_text_size::Ranged for crate::StmtFor {
3628    fn range(&self) -> ruff_text_size::TextRange {
3629        self.range
3630    }
3631}
3632
3633impl ruff_text_size::Ranged for crate::StmtWhile {
3634    fn range(&self) -> ruff_text_size::TextRange {
3635        self.range
3636    }
3637}
3638
3639impl ruff_text_size::Ranged for crate::StmtIf {
3640    fn range(&self) -> ruff_text_size::TextRange {
3641        self.range
3642    }
3643}
3644
3645impl ruff_text_size::Ranged for crate::StmtWith {
3646    fn range(&self) -> ruff_text_size::TextRange {
3647        self.range
3648    }
3649}
3650
3651impl ruff_text_size::Ranged for crate::StmtMatch {
3652    fn range(&self) -> ruff_text_size::TextRange {
3653        self.range
3654    }
3655}
3656
3657impl ruff_text_size::Ranged for crate::StmtRaise {
3658    fn range(&self) -> ruff_text_size::TextRange {
3659        self.range
3660    }
3661}
3662
3663impl ruff_text_size::Ranged for crate::StmtTry {
3664    fn range(&self) -> ruff_text_size::TextRange {
3665        self.range
3666    }
3667}
3668
3669impl ruff_text_size::Ranged for crate::StmtAssert {
3670    fn range(&self) -> ruff_text_size::TextRange {
3671        self.range
3672    }
3673}
3674
3675impl ruff_text_size::Ranged for crate::StmtImport {
3676    fn range(&self) -> ruff_text_size::TextRange {
3677        self.range
3678    }
3679}
3680
3681impl ruff_text_size::Ranged for crate::StmtImportFrom {
3682    fn range(&self) -> ruff_text_size::TextRange {
3683        self.range
3684    }
3685}
3686
3687impl ruff_text_size::Ranged for crate::StmtGlobal {
3688    fn range(&self) -> ruff_text_size::TextRange {
3689        self.range
3690    }
3691}
3692
3693impl ruff_text_size::Ranged for crate::StmtNonlocal {
3694    fn range(&self) -> ruff_text_size::TextRange {
3695        self.range
3696    }
3697}
3698
3699impl ruff_text_size::Ranged for crate::StmtExpr {
3700    fn range(&self) -> ruff_text_size::TextRange {
3701        self.range
3702    }
3703}
3704
3705impl ruff_text_size::Ranged for crate::StmtPass {
3706    fn range(&self) -> ruff_text_size::TextRange {
3707        self.range
3708    }
3709}
3710
3711impl ruff_text_size::Ranged for crate::StmtBreak {
3712    fn range(&self) -> ruff_text_size::TextRange {
3713        self.range
3714    }
3715}
3716
3717impl ruff_text_size::Ranged for crate::StmtContinue {
3718    fn range(&self) -> ruff_text_size::TextRange {
3719        self.range
3720    }
3721}
3722
3723impl ruff_text_size::Ranged for crate::StmtIpyEscapeCommand {
3724    fn range(&self) -> ruff_text_size::TextRange {
3725        self.range
3726    }
3727}
3728
3729impl ruff_text_size::Ranged for crate::ExprBoolOp {
3730    fn range(&self) -> ruff_text_size::TextRange {
3731        self.range
3732    }
3733}
3734
3735impl ruff_text_size::Ranged for crate::ExprNamed {
3736    fn range(&self) -> ruff_text_size::TextRange {
3737        self.range
3738    }
3739}
3740
3741impl ruff_text_size::Ranged for crate::ExprBinOp {
3742    fn range(&self) -> ruff_text_size::TextRange {
3743        self.range
3744    }
3745}
3746
3747impl ruff_text_size::Ranged for crate::ExprUnaryOp {
3748    fn range(&self) -> ruff_text_size::TextRange {
3749        self.range
3750    }
3751}
3752
3753impl ruff_text_size::Ranged for crate::ExprLambda {
3754    fn range(&self) -> ruff_text_size::TextRange {
3755        self.range
3756    }
3757}
3758
3759impl ruff_text_size::Ranged for crate::ExprIf {
3760    fn range(&self) -> ruff_text_size::TextRange {
3761        self.range
3762    }
3763}
3764
3765impl ruff_text_size::Ranged for crate::ExprDict {
3766    fn range(&self) -> ruff_text_size::TextRange {
3767        self.range
3768    }
3769}
3770
3771impl ruff_text_size::Ranged for crate::ExprSet {
3772    fn range(&self) -> ruff_text_size::TextRange {
3773        self.range
3774    }
3775}
3776
3777impl ruff_text_size::Ranged for crate::ExprListComp {
3778    fn range(&self) -> ruff_text_size::TextRange {
3779        self.range
3780    }
3781}
3782
3783impl ruff_text_size::Ranged for crate::ExprSetComp {
3784    fn range(&self) -> ruff_text_size::TextRange {
3785        self.range
3786    }
3787}
3788
3789impl ruff_text_size::Ranged for crate::ExprDictComp {
3790    fn range(&self) -> ruff_text_size::TextRange {
3791        self.range
3792    }
3793}
3794
3795impl ruff_text_size::Ranged for crate::ExprGenerator {
3796    fn range(&self) -> ruff_text_size::TextRange {
3797        self.range
3798    }
3799}
3800
3801impl ruff_text_size::Ranged for crate::ExprAwait {
3802    fn range(&self) -> ruff_text_size::TextRange {
3803        self.range
3804    }
3805}
3806
3807impl ruff_text_size::Ranged for crate::ExprYield {
3808    fn range(&self) -> ruff_text_size::TextRange {
3809        self.range
3810    }
3811}
3812
3813impl ruff_text_size::Ranged for crate::ExprYieldFrom {
3814    fn range(&self) -> ruff_text_size::TextRange {
3815        self.range
3816    }
3817}
3818
3819impl ruff_text_size::Ranged for crate::ExprCompare {
3820    fn range(&self) -> ruff_text_size::TextRange {
3821        self.range
3822    }
3823}
3824
3825impl ruff_text_size::Ranged for crate::ExprCall {
3826    fn range(&self) -> ruff_text_size::TextRange {
3827        self.range
3828    }
3829}
3830
3831impl ruff_text_size::Ranged for crate::ExprFString {
3832    fn range(&self) -> ruff_text_size::TextRange {
3833        self.range
3834    }
3835}
3836
3837impl ruff_text_size::Ranged for crate::ExprTString {
3838    fn range(&self) -> ruff_text_size::TextRange {
3839        self.range
3840    }
3841}
3842
3843impl ruff_text_size::Ranged for crate::ExprStringLiteral {
3844    fn range(&self) -> ruff_text_size::TextRange {
3845        self.range
3846    }
3847}
3848
3849impl ruff_text_size::Ranged for crate::ExprBytesLiteral {
3850    fn range(&self) -> ruff_text_size::TextRange {
3851        self.range
3852    }
3853}
3854
3855impl ruff_text_size::Ranged for crate::ExprNumberLiteral {
3856    fn range(&self) -> ruff_text_size::TextRange {
3857        self.range
3858    }
3859}
3860
3861impl ruff_text_size::Ranged for crate::ExprBooleanLiteral {
3862    fn range(&self) -> ruff_text_size::TextRange {
3863        self.range
3864    }
3865}
3866
3867impl ruff_text_size::Ranged for crate::ExprNoneLiteral {
3868    fn range(&self) -> ruff_text_size::TextRange {
3869        self.range
3870    }
3871}
3872
3873impl ruff_text_size::Ranged for crate::ExprEllipsisLiteral {
3874    fn range(&self) -> ruff_text_size::TextRange {
3875        self.range
3876    }
3877}
3878
3879impl ruff_text_size::Ranged for crate::ExprAttribute {
3880    fn range(&self) -> ruff_text_size::TextRange {
3881        self.range
3882    }
3883}
3884
3885impl ruff_text_size::Ranged for crate::ExprSubscript {
3886    fn range(&self) -> ruff_text_size::TextRange {
3887        self.range
3888    }
3889}
3890
3891impl ruff_text_size::Ranged for crate::ExprStarred {
3892    fn range(&self) -> ruff_text_size::TextRange {
3893        self.range
3894    }
3895}
3896
3897impl ruff_text_size::Ranged for crate::ExprName {
3898    fn range(&self) -> ruff_text_size::TextRange {
3899        self.range
3900    }
3901}
3902
3903impl ruff_text_size::Ranged for crate::ExprList {
3904    fn range(&self) -> ruff_text_size::TextRange {
3905        self.range
3906    }
3907}
3908
3909impl ruff_text_size::Ranged for crate::ExprTuple {
3910    fn range(&self) -> ruff_text_size::TextRange {
3911        self.range
3912    }
3913}
3914
3915impl ruff_text_size::Ranged for crate::ExprSlice {
3916    fn range(&self) -> ruff_text_size::TextRange {
3917        self.range
3918    }
3919}
3920
3921impl ruff_text_size::Ranged for crate::ExprIpyEscapeCommand {
3922    fn range(&self) -> ruff_text_size::TextRange {
3923        self.range
3924    }
3925}
3926
3927impl ruff_text_size::Ranged for crate::ExceptHandlerExceptHandler {
3928    fn range(&self) -> ruff_text_size::TextRange {
3929        self.range
3930    }
3931}
3932
3933impl ruff_text_size::Ranged for crate::InterpolatedElement {
3934    fn range(&self) -> ruff_text_size::TextRange {
3935        self.range
3936    }
3937}
3938
3939impl ruff_text_size::Ranged for crate::InterpolatedStringLiteralElement {
3940    fn range(&self) -> ruff_text_size::TextRange {
3941        self.range
3942    }
3943}
3944
3945impl ruff_text_size::Ranged for crate::PatternMatchValue {
3946    fn range(&self) -> ruff_text_size::TextRange {
3947        self.range
3948    }
3949}
3950
3951impl ruff_text_size::Ranged for crate::PatternMatchSingleton {
3952    fn range(&self) -> ruff_text_size::TextRange {
3953        self.range
3954    }
3955}
3956
3957impl ruff_text_size::Ranged for crate::PatternMatchSequence {
3958    fn range(&self) -> ruff_text_size::TextRange {
3959        self.range
3960    }
3961}
3962
3963impl ruff_text_size::Ranged for crate::PatternMatchMapping {
3964    fn range(&self) -> ruff_text_size::TextRange {
3965        self.range
3966    }
3967}
3968
3969impl ruff_text_size::Ranged for crate::PatternMatchClass {
3970    fn range(&self) -> ruff_text_size::TextRange {
3971        self.range
3972    }
3973}
3974
3975impl ruff_text_size::Ranged for crate::PatternMatchStar {
3976    fn range(&self) -> ruff_text_size::TextRange {
3977        self.range
3978    }
3979}
3980
3981impl ruff_text_size::Ranged for crate::PatternMatchAs {
3982    fn range(&self) -> ruff_text_size::TextRange {
3983        self.range
3984    }
3985}
3986
3987impl ruff_text_size::Ranged for crate::PatternMatchOr {
3988    fn range(&self) -> ruff_text_size::TextRange {
3989        self.range
3990    }
3991}
3992
3993impl ruff_text_size::Ranged for crate::TypeParamTypeVar {
3994    fn range(&self) -> ruff_text_size::TextRange {
3995        self.range
3996    }
3997}
3998
3999impl ruff_text_size::Ranged for crate::TypeParamTypeVarTuple {
4000    fn range(&self) -> ruff_text_size::TextRange {
4001        self.range
4002    }
4003}
4004
4005impl ruff_text_size::Ranged for crate::TypeParamParamSpec {
4006    fn range(&self) -> ruff_text_size::TextRange {
4007        self.range
4008    }
4009}
4010
4011impl ruff_text_size::Ranged for crate::InterpolatedStringFormatSpec {
4012    fn range(&self) -> ruff_text_size::TextRange {
4013        self.range
4014    }
4015}
4016
4017impl ruff_text_size::Ranged for crate::PatternArguments {
4018    fn range(&self) -> ruff_text_size::TextRange {
4019        self.range
4020    }
4021}
4022
4023impl ruff_text_size::Ranged for crate::PatternKeyword {
4024    fn range(&self) -> ruff_text_size::TextRange {
4025        self.range
4026    }
4027}
4028
4029impl ruff_text_size::Ranged for crate::Comprehension {
4030    fn range(&self) -> ruff_text_size::TextRange {
4031        self.range
4032    }
4033}
4034
4035impl ruff_text_size::Ranged for crate::Arguments {
4036    fn range(&self) -> ruff_text_size::TextRange {
4037        self.range
4038    }
4039}
4040
4041impl ruff_text_size::Ranged for crate::Parameters {
4042    fn range(&self) -> ruff_text_size::TextRange {
4043        self.range
4044    }
4045}
4046
4047impl ruff_text_size::Ranged for crate::Parameter {
4048    fn range(&self) -> ruff_text_size::TextRange {
4049        self.range
4050    }
4051}
4052
4053impl ruff_text_size::Ranged for crate::ParameterWithDefault {
4054    fn range(&self) -> ruff_text_size::TextRange {
4055        self.range
4056    }
4057}
4058
4059impl ruff_text_size::Ranged for crate::Keyword {
4060    fn range(&self) -> ruff_text_size::TextRange {
4061        self.range
4062    }
4063}
4064
4065impl ruff_text_size::Ranged for crate::Alias {
4066    fn range(&self) -> ruff_text_size::TextRange {
4067        self.range
4068    }
4069}
4070
4071impl ruff_text_size::Ranged for crate::WithItem {
4072    fn range(&self) -> ruff_text_size::TextRange {
4073        self.range
4074    }
4075}
4076
4077impl ruff_text_size::Ranged for crate::MatchCase {
4078    fn range(&self) -> ruff_text_size::TextRange {
4079        self.range
4080    }
4081}
4082
4083impl ruff_text_size::Ranged for crate::Decorator {
4084    fn range(&self) -> ruff_text_size::TextRange {
4085        self.range
4086    }
4087}
4088
4089impl ruff_text_size::Ranged for crate::ElifElseClause {
4090    fn range(&self) -> ruff_text_size::TextRange {
4091        self.range
4092    }
4093}
4094
4095impl ruff_text_size::Ranged for crate::TypeParams {
4096    fn range(&self) -> ruff_text_size::TextRange {
4097        self.range
4098    }
4099}
4100
4101impl ruff_text_size::Ranged for crate::FString {
4102    fn range(&self) -> ruff_text_size::TextRange {
4103        self.range
4104    }
4105}
4106
4107impl ruff_text_size::Ranged for crate::TString {
4108    fn range(&self) -> ruff_text_size::TextRange {
4109        self.range
4110    }
4111}
4112
4113impl ruff_text_size::Ranged for crate::StringLiteral {
4114    fn range(&self) -> ruff_text_size::TextRange {
4115        self.range
4116    }
4117}
4118
4119impl ruff_text_size::Ranged for crate::BytesLiteral {
4120    fn range(&self) -> ruff_text_size::TextRange {
4121        self.range
4122    }
4123}
4124
4125impl ruff_text_size::Ranged for crate::Identifier {
4126    fn range(&self) -> ruff_text_size::TextRange {
4127        self.range
4128    }
4129}
4130
4131impl crate::HasNodeIndex for crate::ModModule {
4132    fn node_index(&self) -> &crate::AtomicNodeIndex {
4133        &self.node_index
4134    }
4135}
4136
4137impl crate::HasNodeIndex for crate::ModExpression {
4138    fn node_index(&self) -> &crate::AtomicNodeIndex {
4139        &self.node_index
4140    }
4141}
4142
4143impl crate::HasNodeIndex for crate::StmtFunctionDef {
4144    fn node_index(&self) -> &crate::AtomicNodeIndex {
4145        &self.node_index
4146    }
4147}
4148
4149impl crate::HasNodeIndex for crate::StmtClassDef {
4150    fn node_index(&self) -> &crate::AtomicNodeIndex {
4151        &self.node_index
4152    }
4153}
4154
4155impl crate::HasNodeIndex for crate::StmtReturn {
4156    fn node_index(&self) -> &crate::AtomicNodeIndex {
4157        &self.node_index
4158    }
4159}
4160
4161impl crate::HasNodeIndex for crate::StmtDelete {
4162    fn node_index(&self) -> &crate::AtomicNodeIndex {
4163        &self.node_index
4164    }
4165}
4166
4167impl crate::HasNodeIndex for crate::StmtTypeAlias {
4168    fn node_index(&self) -> &crate::AtomicNodeIndex {
4169        &self.node_index
4170    }
4171}
4172
4173impl crate::HasNodeIndex for crate::StmtAssign {
4174    fn node_index(&self) -> &crate::AtomicNodeIndex {
4175        &self.node_index
4176    }
4177}
4178
4179impl crate::HasNodeIndex for crate::StmtAugAssign {
4180    fn node_index(&self) -> &crate::AtomicNodeIndex {
4181        &self.node_index
4182    }
4183}
4184
4185impl crate::HasNodeIndex for crate::StmtAnnAssign {
4186    fn node_index(&self) -> &crate::AtomicNodeIndex {
4187        &self.node_index
4188    }
4189}
4190
4191impl crate::HasNodeIndex for crate::StmtFor {
4192    fn node_index(&self) -> &crate::AtomicNodeIndex {
4193        &self.node_index
4194    }
4195}
4196
4197impl crate::HasNodeIndex for crate::StmtWhile {
4198    fn node_index(&self) -> &crate::AtomicNodeIndex {
4199        &self.node_index
4200    }
4201}
4202
4203impl crate::HasNodeIndex for crate::StmtIf {
4204    fn node_index(&self) -> &crate::AtomicNodeIndex {
4205        &self.node_index
4206    }
4207}
4208
4209impl crate::HasNodeIndex for crate::StmtWith {
4210    fn node_index(&self) -> &crate::AtomicNodeIndex {
4211        &self.node_index
4212    }
4213}
4214
4215impl crate::HasNodeIndex for crate::StmtMatch {
4216    fn node_index(&self) -> &crate::AtomicNodeIndex {
4217        &self.node_index
4218    }
4219}
4220
4221impl crate::HasNodeIndex for crate::StmtRaise {
4222    fn node_index(&self) -> &crate::AtomicNodeIndex {
4223        &self.node_index
4224    }
4225}
4226
4227impl crate::HasNodeIndex for crate::StmtTry {
4228    fn node_index(&self) -> &crate::AtomicNodeIndex {
4229        &self.node_index
4230    }
4231}
4232
4233impl crate::HasNodeIndex for crate::StmtAssert {
4234    fn node_index(&self) -> &crate::AtomicNodeIndex {
4235        &self.node_index
4236    }
4237}
4238
4239impl crate::HasNodeIndex for crate::StmtImport {
4240    fn node_index(&self) -> &crate::AtomicNodeIndex {
4241        &self.node_index
4242    }
4243}
4244
4245impl crate::HasNodeIndex for crate::StmtImportFrom {
4246    fn node_index(&self) -> &crate::AtomicNodeIndex {
4247        &self.node_index
4248    }
4249}
4250
4251impl crate::HasNodeIndex for crate::StmtGlobal {
4252    fn node_index(&self) -> &crate::AtomicNodeIndex {
4253        &self.node_index
4254    }
4255}
4256
4257impl crate::HasNodeIndex for crate::StmtNonlocal {
4258    fn node_index(&self) -> &crate::AtomicNodeIndex {
4259        &self.node_index
4260    }
4261}
4262
4263impl crate::HasNodeIndex for crate::StmtExpr {
4264    fn node_index(&self) -> &crate::AtomicNodeIndex {
4265        &self.node_index
4266    }
4267}
4268
4269impl crate::HasNodeIndex for crate::StmtPass {
4270    fn node_index(&self) -> &crate::AtomicNodeIndex {
4271        &self.node_index
4272    }
4273}
4274
4275impl crate::HasNodeIndex for crate::StmtBreak {
4276    fn node_index(&self) -> &crate::AtomicNodeIndex {
4277        &self.node_index
4278    }
4279}
4280
4281impl crate::HasNodeIndex for crate::StmtContinue {
4282    fn node_index(&self) -> &crate::AtomicNodeIndex {
4283        &self.node_index
4284    }
4285}
4286
4287impl crate::HasNodeIndex for crate::StmtIpyEscapeCommand {
4288    fn node_index(&self) -> &crate::AtomicNodeIndex {
4289        &self.node_index
4290    }
4291}
4292
4293impl crate::HasNodeIndex for crate::ExprBoolOp {
4294    fn node_index(&self) -> &crate::AtomicNodeIndex {
4295        &self.node_index
4296    }
4297}
4298
4299impl crate::HasNodeIndex for crate::ExprNamed {
4300    fn node_index(&self) -> &crate::AtomicNodeIndex {
4301        &self.node_index
4302    }
4303}
4304
4305impl crate::HasNodeIndex for crate::ExprBinOp {
4306    fn node_index(&self) -> &crate::AtomicNodeIndex {
4307        &self.node_index
4308    }
4309}
4310
4311impl crate::HasNodeIndex for crate::ExprUnaryOp {
4312    fn node_index(&self) -> &crate::AtomicNodeIndex {
4313        &self.node_index
4314    }
4315}
4316
4317impl crate::HasNodeIndex for crate::ExprLambda {
4318    fn node_index(&self) -> &crate::AtomicNodeIndex {
4319        &self.node_index
4320    }
4321}
4322
4323impl crate::HasNodeIndex for crate::ExprIf {
4324    fn node_index(&self) -> &crate::AtomicNodeIndex {
4325        &self.node_index
4326    }
4327}
4328
4329impl crate::HasNodeIndex for crate::ExprDict {
4330    fn node_index(&self) -> &crate::AtomicNodeIndex {
4331        &self.node_index
4332    }
4333}
4334
4335impl crate::HasNodeIndex for crate::ExprSet {
4336    fn node_index(&self) -> &crate::AtomicNodeIndex {
4337        &self.node_index
4338    }
4339}
4340
4341impl crate::HasNodeIndex for crate::ExprListComp {
4342    fn node_index(&self) -> &crate::AtomicNodeIndex {
4343        &self.node_index
4344    }
4345}
4346
4347impl crate::HasNodeIndex for crate::ExprSetComp {
4348    fn node_index(&self) -> &crate::AtomicNodeIndex {
4349        &self.node_index
4350    }
4351}
4352
4353impl crate::HasNodeIndex for crate::ExprDictComp {
4354    fn node_index(&self) -> &crate::AtomicNodeIndex {
4355        &self.node_index
4356    }
4357}
4358
4359impl crate::HasNodeIndex for crate::ExprGenerator {
4360    fn node_index(&self) -> &crate::AtomicNodeIndex {
4361        &self.node_index
4362    }
4363}
4364
4365impl crate::HasNodeIndex for crate::ExprAwait {
4366    fn node_index(&self) -> &crate::AtomicNodeIndex {
4367        &self.node_index
4368    }
4369}
4370
4371impl crate::HasNodeIndex for crate::ExprYield {
4372    fn node_index(&self) -> &crate::AtomicNodeIndex {
4373        &self.node_index
4374    }
4375}
4376
4377impl crate::HasNodeIndex for crate::ExprYieldFrom {
4378    fn node_index(&self) -> &crate::AtomicNodeIndex {
4379        &self.node_index
4380    }
4381}
4382
4383impl crate::HasNodeIndex for crate::ExprCompare {
4384    fn node_index(&self) -> &crate::AtomicNodeIndex {
4385        &self.node_index
4386    }
4387}
4388
4389impl crate::HasNodeIndex for crate::ExprCall {
4390    fn node_index(&self) -> &crate::AtomicNodeIndex {
4391        &self.node_index
4392    }
4393}
4394
4395impl crate::HasNodeIndex for crate::ExprFString {
4396    fn node_index(&self) -> &crate::AtomicNodeIndex {
4397        &self.node_index
4398    }
4399}
4400
4401impl crate::HasNodeIndex for crate::ExprTString {
4402    fn node_index(&self) -> &crate::AtomicNodeIndex {
4403        &self.node_index
4404    }
4405}
4406
4407impl crate::HasNodeIndex for crate::ExprStringLiteral {
4408    fn node_index(&self) -> &crate::AtomicNodeIndex {
4409        &self.node_index
4410    }
4411}
4412
4413impl crate::HasNodeIndex for crate::ExprBytesLiteral {
4414    fn node_index(&self) -> &crate::AtomicNodeIndex {
4415        &self.node_index
4416    }
4417}
4418
4419impl crate::HasNodeIndex for crate::ExprNumberLiteral {
4420    fn node_index(&self) -> &crate::AtomicNodeIndex {
4421        &self.node_index
4422    }
4423}
4424
4425impl crate::HasNodeIndex for crate::ExprBooleanLiteral {
4426    fn node_index(&self) -> &crate::AtomicNodeIndex {
4427        &self.node_index
4428    }
4429}
4430
4431impl crate::HasNodeIndex for crate::ExprNoneLiteral {
4432    fn node_index(&self) -> &crate::AtomicNodeIndex {
4433        &self.node_index
4434    }
4435}
4436
4437impl crate::HasNodeIndex for crate::ExprEllipsisLiteral {
4438    fn node_index(&self) -> &crate::AtomicNodeIndex {
4439        &self.node_index
4440    }
4441}
4442
4443impl crate::HasNodeIndex for crate::ExprAttribute {
4444    fn node_index(&self) -> &crate::AtomicNodeIndex {
4445        &self.node_index
4446    }
4447}
4448
4449impl crate::HasNodeIndex for crate::ExprSubscript {
4450    fn node_index(&self) -> &crate::AtomicNodeIndex {
4451        &self.node_index
4452    }
4453}
4454
4455impl crate::HasNodeIndex for crate::ExprStarred {
4456    fn node_index(&self) -> &crate::AtomicNodeIndex {
4457        &self.node_index
4458    }
4459}
4460
4461impl crate::HasNodeIndex for crate::ExprName {
4462    fn node_index(&self) -> &crate::AtomicNodeIndex {
4463        &self.node_index
4464    }
4465}
4466
4467impl crate::HasNodeIndex for crate::ExprList {
4468    fn node_index(&self) -> &crate::AtomicNodeIndex {
4469        &self.node_index
4470    }
4471}
4472
4473impl crate::HasNodeIndex for crate::ExprTuple {
4474    fn node_index(&self) -> &crate::AtomicNodeIndex {
4475        &self.node_index
4476    }
4477}
4478
4479impl crate::HasNodeIndex for crate::ExprSlice {
4480    fn node_index(&self) -> &crate::AtomicNodeIndex {
4481        &self.node_index
4482    }
4483}
4484
4485impl crate::HasNodeIndex for crate::ExprIpyEscapeCommand {
4486    fn node_index(&self) -> &crate::AtomicNodeIndex {
4487        &self.node_index
4488    }
4489}
4490
4491impl crate::HasNodeIndex for crate::ExceptHandlerExceptHandler {
4492    fn node_index(&self) -> &crate::AtomicNodeIndex {
4493        &self.node_index
4494    }
4495}
4496
4497impl crate::HasNodeIndex for crate::InterpolatedElement {
4498    fn node_index(&self) -> &crate::AtomicNodeIndex {
4499        &self.node_index
4500    }
4501}
4502
4503impl crate::HasNodeIndex for crate::InterpolatedStringLiteralElement {
4504    fn node_index(&self) -> &crate::AtomicNodeIndex {
4505        &self.node_index
4506    }
4507}
4508
4509impl crate::HasNodeIndex for crate::PatternMatchValue {
4510    fn node_index(&self) -> &crate::AtomicNodeIndex {
4511        &self.node_index
4512    }
4513}
4514
4515impl crate::HasNodeIndex for crate::PatternMatchSingleton {
4516    fn node_index(&self) -> &crate::AtomicNodeIndex {
4517        &self.node_index
4518    }
4519}
4520
4521impl crate::HasNodeIndex for crate::PatternMatchSequence {
4522    fn node_index(&self) -> &crate::AtomicNodeIndex {
4523        &self.node_index
4524    }
4525}
4526
4527impl crate::HasNodeIndex for crate::PatternMatchMapping {
4528    fn node_index(&self) -> &crate::AtomicNodeIndex {
4529        &self.node_index
4530    }
4531}
4532
4533impl crate::HasNodeIndex for crate::PatternMatchClass {
4534    fn node_index(&self) -> &crate::AtomicNodeIndex {
4535        &self.node_index
4536    }
4537}
4538
4539impl crate::HasNodeIndex for crate::PatternMatchStar {
4540    fn node_index(&self) -> &crate::AtomicNodeIndex {
4541        &self.node_index
4542    }
4543}
4544
4545impl crate::HasNodeIndex for crate::PatternMatchAs {
4546    fn node_index(&self) -> &crate::AtomicNodeIndex {
4547        &self.node_index
4548    }
4549}
4550
4551impl crate::HasNodeIndex for crate::PatternMatchOr {
4552    fn node_index(&self) -> &crate::AtomicNodeIndex {
4553        &self.node_index
4554    }
4555}
4556
4557impl crate::HasNodeIndex for crate::TypeParamTypeVar {
4558    fn node_index(&self) -> &crate::AtomicNodeIndex {
4559        &self.node_index
4560    }
4561}
4562
4563impl crate::HasNodeIndex for crate::TypeParamTypeVarTuple {
4564    fn node_index(&self) -> &crate::AtomicNodeIndex {
4565        &self.node_index
4566    }
4567}
4568
4569impl crate::HasNodeIndex for crate::TypeParamParamSpec {
4570    fn node_index(&self) -> &crate::AtomicNodeIndex {
4571        &self.node_index
4572    }
4573}
4574
4575impl crate::HasNodeIndex for crate::InterpolatedStringFormatSpec {
4576    fn node_index(&self) -> &crate::AtomicNodeIndex {
4577        &self.node_index
4578    }
4579}
4580
4581impl crate::HasNodeIndex for crate::PatternArguments {
4582    fn node_index(&self) -> &crate::AtomicNodeIndex {
4583        &self.node_index
4584    }
4585}
4586
4587impl crate::HasNodeIndex for crate::PatternKeyword {
4588    fn node_index(&self) -> &crate::AtomicNodeIndex {
4589        &self.node_index
4590    }
4591}
4592
4593impl crate::HasNodeIndex for crate::Comprehension {
4594    fn node_index(&self) -> &crate::AtomicNodeIndex {
4595        &self.node_index
4596    }
4597}
4598
4599impl crate::HasNodeIndex for crate::Arguments {
4600    fn node_index(&self) -> &crate::AtomicNodeIndex {
4601        &self.node_index
4602    }
4603}
4604
4605impl crate::HasNodeIndex for crate::Parameters {
4606    fn node_index(&self) -> &crate::AtomicNodeIndex {
4607        &self.node_index
4608    }
4609}
4610
4611impl crate::HasNodeIndex for crate::Parameter {
4612    fn node_index(&self) -> &crate::AtomicNodeIndex {
4613        &self.node_index
4614    }
4615}
4616
4617impl crate::HasNodeIndex for crate::ParameterWithDefault {
4618    fn node_index(&self) -> &crate::AtomicNodeIndex {
4619        &self.node_index
4620    }
4621}
4622
4623impl crate::HasNodeIndex for crate::Keyword {
4624    fn node_index(&self) -> &crate::AtomicNodeIndex {
4625        &self.node_index
4626    }
4627}
4628
4629impl crate::HasNodeIndex for crate::Alias {
4630    fn node_index(&self) -> &crate::AtomicNodeIndex {
4631        &self.node_index
4632    }
4633}
4634
4635impl crate::HasNodeIndex for crate::WithItem {
4636    fn node_index(&self) -> &crate::AtomicNodeIndex {
4637        &self.node_index
4638    }
4639}
4640
4641impl crate::HasNodeIndex for crate::MatchCase {
4642    fn node_index(&self) -> &crate::AtomicNodeIndex {
4643        &self.node_index
4644    }
4645}
4646
4647impl crate::HasNodeIndex for crate::Decorator {
4648    fn node_index(&self) -> &crate::AtomicNodeIndex {
4649        &self.node_index
4650    }
4651}
4652
4653impl crate::HasNodeIndex for crate::ElifElseClause {
4654    fn node_index(&self) -> &crate::AtomicNodeIndex {
4655        &self.node_index
4656    }
4657}
4658
4659impl crate::HasNodeIndex for crate::TypeParams {
4660    fn node_index(&self) -> &crate::AtomicNodeIndex {
4661        &self.node_index
4662    }
4663}
4664
4665impl crate::HasNodeIndex for crate::FString {
4666    fn node_index(&self) -> &crate::AtomicNodeIndex {
4667        &self.node_index
4668    }
4669}
4670
4671impl crate::HasNodeIndex for crate::TString {
4672    fn node_index(&self) -> &crate::AtomicNodeIndex {
4673        &self.node_index
4674    }
4675}
4676
4677impl crate::HasNodeIndex for crate::StringLiteral {
4678    fn node_index(&self) -> &crate::AtomicNodeIndex {
4679        &self.node_index
4680    }
4681}
4682
4683impl crate::HasNodeIndex for crate::BytesLiteral {
4684    fn node_index(&self) -> &crate::AtomicNodeIndex {
4685        &self.node_index
4686    }
4687}
4688
4689impl crate::HasNodeIndex for crate::Identifier {
4690    fn node_index(&self) -> &crate::AtomicNodeIndex {
4691        &self.node_index
4692    }
4693}
4694
4695impl Mod {
4696    #[allow(unused)]
4697    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
4698    where
4699        V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized,
4700    {
4701        match self {
4702            Mod::Module(node) => node.visit_source_order(visitor),
4703            Mod::Expression(node) => node.visit_source_order(visitor),
4704        }
4705    }
4706}
4707
4708impl Stmt {
4709    #[allow(unused)]
4710    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
4711    where
4712        V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized,
4713    {
4714        match self {
4715            Stmt::FunctionDef(node) => node.visit_source_order(visitor),
4716            Stmt::ClassDef(node) => node.visit_source_order(visitor),
4717            Stmt::Return(node) => node.visit_source_order(visitor),
4718            Stmt::Delete(node) => node.visit_source_order(visitor),
4719            Stmt::TypeAlias(node) => node.visit_source_order(visitor),
4720            Stmt::Assign(node) => node.visit_source_order(visitor),
4721            Stmt::AugAssign(node) => node.visit_source_order(visitor),
4722            Stmt::AnnAssign(node) => node.visit_source_order(visitor),
4723            Stmt::For(node) => node.visit_source_order(visitor),
4724            Stmt::While(node) => node.visit_source_order(visitor),
4725            Stmt::If(node) => node.visit_source_order(visitor),
4726            Stmt::With(node) => node.visit_source_order(visitor),
4727            Stmt::Match(node) => node.visit_source_order(visitor),
4728            Stmt::Raise(node) => node.visit_source_order(visitor),
4729            Stmt::Try(node) => node.visit_source_order(visitor),
4730            Stmt::Assert(node) => node.visit_source_order(visitor),
4731            Stmt::Import(node) => node.visit_source_order(visitor),
4732            Stmt::ImportFrom(node) => node.visit_source_order(visitor),
4733            Stmt::Global(node) => node.visit_source_order(visitor),
4734            Stmt::Nonlocal(node) => node.visit_source_order(visitor),
4735            Stmt::Expr(node) => node.visit_source_order(visitor),
4736            Stmt::Pass(node) => node.visit_source_order(visitor),
4737            Stmt::Break(node) => node.visit_source_order(visitor),
4738            Stmt::Continue(node) => node.visit_source_order(visitor),
4739            Stmt::IpyEscapeCommand(node) => node.visit_source_order(visitor),
4740        }
4741    }
4742}
4743
4744impl Expr {
4745    #[allow(unused)]
4746    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
4747    where
4748        V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized,
4749    {
4750        match self {
4751            Expr::BoolOp(node) => node.visit_source_order(visitor),
4752            Expr::Named(node) => node.visit_source_order(visitor),
4753            Expr::BinOp(node) => node.visit_source_order(visitor),
4754            Expr::UnaryOp(node) => node.visit_source_order(visitor),
4755            Expr::Lambda(node) => node.visit_source_order(visitor),
4756            Expr::If(node) => node.visit_source_order(visitor),
4757            Expr::Dict(node) => node.visit_source_order(visitor),
4758            Expr::Set(node) => node.visit_source_order(visitor),
4759            Expr::ListComp(node) => node.visit_source_order(visitor),
4760            Expr::SetComp(node) => node.visit_source_order(visitor),
4761            Expr::DictComp(node) => node.visit_source_order(visitor),
4762            Expr::Generator(node) => node.visit_source_order(visitor),
4763            Expr::Await(node) => node.visit_source_order(visitor),
4764            Expr::Yield(node) => node.visit_source_order(visitor),
4765            Expr::YieldFrom(node) => node.visit_source_order(visitor),
4766            Expr::Compare(node) => node.visit_source_order(visitor),
4767            Expr::Call(node) => node.visit_source_order(visitor),
4768            Expr::FString(node) => node.visit_source_order(visitor),
4769            Expr::TString(node) => node.visit_source_order(visitor),
4770            Expr::StringLiteral(node) => node.visit_source_order(visitor),
4771            Expr::BytesLiteral(node) => node.visit_source_order(visitor),
4772            Expr::NumberLiteral(node) => node.visit_source_order(visitor),
4773            Expr::BooleanLiteral(node) => node.visit_source_order(visitor),
4774            Expr::NoneLiteral(node) => node.visit_source_order(visitor),
4775            Expr::EllipsisLiteral(node) => node.visit_source_order(visitor),
4776            Expr::Attribute(node) => node.visit_source_order(visitor),
4777            Expr::Subscript(node) => node.visit_source_order(visitor),
4778            Expr::Starred(node) => node.visit_source_order(visitor),
4779            Expr::Name(node) => node.visit_source_order(visitor),
4780            Expr::List(node) => node.visit_source_order(visitor),
4781            Expr::Tuple(node) => node.visit_source_order(visitor),
4782            Expr::Slice(node) => node.visit_source_order(visitor),
4783            Expr::IpyEscapeCommand(node) => node.visit_source_order(visitor),
4784        }
4785    }
4786}
4787
4788impl ExceptHandler {
4789    #[allow(unused)]
4790    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
4791    where
4792        V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized,
4793    {
4794        match self {
4795            ExceptHandler::ExceptHandler(node) => node.visit_source_order(visitor),
4796        }
4797    }
4798}
4799
4800impl InterpolatedStringElement {
4801    #[allow(unused)]
4802    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
4803    where
4804        V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized,
4805    {
4806        match self {
4807            InterpolatedStringElement::Interpolation(node) => node.visit_source_order(visitor),
4808            InterpolatedStringElement::Literal(node) => node.visit_source_order(visitor),
4809        }
4810    }
4811}
4812
4813impl Pattern {
4814    #[allow(unused)]
4815    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
4816    where
4817        V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized,
4818    {
4819        match self {
4820            Pattern::MatchValue(node) => node.visit_source_order(visitor),
4821            Pattern::MatchSingleton(node) => node.visit_source_order(visitor),
4822            Pattern::MatchSequence(node) => node.visit_source_order(visitor),
4823            Pattern::MatchMapping(node) => node.visit_source_order(visitor),
4824            Pattern::MatchClass(node) => node.visit_source_order(visitor),
4825            Pattern::MatchStar(node) => node.visit_source_order(visitor),
4826            Pattern::MatchAs(node) => node.visit_source_order(visitor),
4827            Pattern::MatchOr(node) => node.visit_source_order(visitor),
4828        }
4829    }
4830}
4831
4832impl TypeParam {
4833    #[allow(unused)]
4834    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
4835    where
4836        V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized,
4837    {
4838        match self {
4839            TypeParam::TypeVar(node) => node.visit_source_order(visitor),
4840            TypeParam::TypeVarTuple(node) => node.visit_source_order(visitor),
4841            TypeParam::ParamSpec(node) => node.visit_source_order(visitor),
4842        }
4843    }
4844}
4845
4846/// See also [mod](https://docs.python.org/3/library/ast.html#ast.mod)
4847#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)]
4848#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
4849pub enum ModRef<'a> {
4850    Module(&'a crate::ModModule),
4851    Expression(&'a crate::ModExpression),
4852}
4853
4854impl<'a> From<&'a Mod> for ModRef<'a> {
4855    fn from(node: &'a Mod) -> Self {
4856        match node {
4857            Mod::Module(node) => ModRef::Module(node),
4858            Mod::Expression(node) => ModRef::Expression(node),
4859        }
4860    }
4861}
4862
4863impl<'a> From<&'a crate::ModModule> for ModRef<'a> {
4864    fn from(node: &'a crate::ModModule) -> Self {
4865        Self::Module(node)
4866    }
4867}
4868
4869impl<'a> From<&'a crate::ModExpression> for ModRef<'a> {
4870    fn from(node: &'a crate::ModExpression) -> Self {
4871        Self::Expression(node)
4872    }
4873}
4874
4875impl ruff_text_size::Ranged for ModRef<'_> {
4876    fn range(&self) -> ruff_text_size::TextRange {
4877        match self {
4878            Self::Module(node) => node.range(),
4879            Self::Expression(node) => node.range(),
4880        }
4881    }
4882}
4883
4884impl crate::HasNodeIndex for ModRef<'_> {
4885    fn node_index(&self) -> &crate::AtomicNodeIndex {
4886        match self {
4887            Self::Module(node) => node.node_index(),
4888            Self::Expression(node) => node.node_index(),
4889        }
4890    }
4891}
4892
4893/// See also [stmt](https://docs.python.org/3/library/ast.html#ast.stmt)
4894#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)]
4895#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
4896pub enum StmtRef<'a> {
4897    #[is(name = "function_def_stmt")]
4898    FunctionDef(&'a crate::StmtFunctionDef),
4899    #[is(name = "class_def_stmt")]
4900    ClassDef(&'a crate::StmtClassDef),
4901    #[is(name = "return_stmt")]
4902    Return(&'a crate::StmtReturn),
4903    #[is(name = "delete_stmt")]
4904    Delete(&'a crate::StmtDelete),
4905    #[is(name = "type_alias_stmt")]
4906    TypeAlias(&'a crate::StmtTypeAlias),
4907    #[is(name = "assign_stmt")]
4908    Assign(&'a crate::StmtAssign),
4909    #[is(name = "aug_assign_stmt")]
4910    AugAssign(&'a crate::StmtAugAssign),
4911    #[is(name = "ann_assign_stmt")]
4912    AnnAssign(&'a crate::StmtAnnAssign),
4913    #[is(name = "for_stmt")]
4914    For(&'a crate::StmtFor),
4915    #[is(name = "while_stmt")]
4916    While(&'a crate::StmtWhile),
4917    #[is(name = "if_stmt")]
4918    If(&'a crate::StmtIf),
4919    #[is(name = "with_stmt")]
4920    With(&'a crate::StmtWith),
4921    #[is(name = "match_stmt")]
4922    Match(&'a crate::StmtMatch),
4923    #[is(name = "raise_stmt")]
4924    Raise(&'a crate::StmtRaise),
4925    #[is(name = "try_stmt")]
4926    Try(&'a crate::StmtTry),
4927    #[is(name = "assert_stmt")]
4928    Assert(&'a crate::StmtAssert),
4929    #[is(name = "import_stmt")]
4930    Import(&'a crate::StmtImport),
4931    #[is(name = "import_from_stmt")]
4932    ImportFrom(&'a crate::StmtImportFrom),
4933    #[is(name = "global_stmt")]
4934    Global(&'a crate::StmtGlobal),
4935    #[is(name = "nonlocal_stmt")]
4936    Nonlocal(&'a crate::StmtNonlocal),
4937    #[is(name = "expr_stmt")]
4938    Expr(&'a crate::StmtExpr),
4939    #[is(name = "pass_stmt")]
4940    Pass(&'a crate::StmtPass),
4941    #[is(name = "break_stmt")]
4942    Break(&'a crate::StmtBreak),
4943    #[is(name = "continue_stmt")]
4944    Continue(&'a crate::StmtContinue),
4945    #[is(name = "ipy_escape_command_stmt")]
4946    IpyEscapeCommand(&'a crate::StmtIpyEscapeCommand),
4947}
4948
4949impl<'a> From<&'a Stmt> for StmtRef<'a> {
4950    fn from(node: &'a Stmt) -> Self {
4951        match node {
4952            Stmt::FunctionDef(node) => StmtRef::FunctionDef(node),
4953            Stmt::ClassDef(node) => StmtRef::ClassDef(node),
4954            Stmt::Return(node) => StmtRef::Return(node),
4955            Stmt::Delete(node) => StmtRef::Delete(node),
4956            Stmt::TypeAlias(node) => StmtRef::TypeAlias(node),
4957            Stmt::Assign(node) => StmtRef::Assign(node),
4958            Stmt::AugAssign(node) => StmtRef::AugAssign(node),
4959            Stmt::AnnAssign(node) => StmtRef::AnnAssign(node),
4960            Stmt::For(node) => StmtRef::For(node),
4961            Stmt::While(node) => StmtRef::While(node),
4962            Stmt::If(node) => StmtRef::If(node),
4963            Stmt::With(node) => StmtRef::With(node),
4964            Stmt::Match(node) => StmtRef::Match(node),
4965            Stmt::Raise(node) => StmtRef::Raise(node),
4966            Stmt::Try(node) => StmtRef::Try(node),
4967            Stmt::Assert(node) => StmtRef::Assert(node),
4968            Stmt::Import(node) => StmtRef::Import(node),
4969            Stmt::ImportFrom(node) => StmtRef::ImportFrom(node),
4970            Stmt::Global(node) => StmtRef::Global(node),
4971            Stmt::Nonlocal(node) => StmtRef::Nonlocal(node),
4972            Stmt::Expr(node) => StmtRef::Expr(node),
4973            Stmt::Pass(node) => StmtRef::Pass(node),
4974            Stmt::Break(node) => StmtRef::Break(node),
4975            Stmt::Continue(node) => StmtRef::Continue(node),
4976            Stmt::IpyEscapeCommand(node) => StmtRef::IpyEscapeCommand(node),
4977        }
4978    }
4979}
4980
4981impl<'a> From<&'a crate::StmtFunctionDef> for StmtRef<'a> {
4982    fn from(node: &'a crate::StmtFunctionDef) -> Self {
4983        Self::FunctionDef(node)
4984    }
4985}
4986
4987impl<'a> From<&'a crate::StmtClassDef> for StmtRef<'a> {
4988    fn from(node: &'a crate::StmtClassDef) -> Self {
4989        Self::ClassDef(node)
4990    }
4991}
4992
4993impl<'a> From<&'a crate::StmtReturn> for StmtRef<'a> {
4994    fn from(node: &'a crate::StmtReturn) -> Self {
4995        Self::Return(node)
4996    }
4997}
4998
4999impl<'a> From<&'a crate::StmtDelete> for StmtRef<'a> {
5000    fn from(node: &'a crate::StmtDelete) -> Self {
5001        Self::Delete(node)
5002    }
5003}
5004
5005impl<'a> From<&'a crate::StmtTypeAlias> for StmtRef<'a> {
5006    fn from(node: &'a crate::StmtTypeAlias) -> Self {
5007        Self::TypeAlias(node)
5008    }
5009}
5010
5011impl<'a> From<&'a crate::StmtAssign> for StmtRef<'a> {
5012    fn from(node: &'a crate::StmtAssign) -> Self {
5013        Self::Assign(node)
5014    }
5015}
5016
5017impl<'a> From<&'a crate::StmtAugAssign> for StmtRef<'a> {
5018    fn from(node: &'a crate::StmtAugAssign) -> Self {
5019        Self::AugAssign(node)
5020    }
5021}
5022
5023impl<'a> From<&'a crate::StmtAnnAssign> for StmtRef<'a> {
5024    fn from(node: &'a crate::StmtAnnAssign) -> Self {
5025        Self::AnnAssign(node)
5026    }
5027}
5028
5029impl<'a> From<&'a crate::StmtFor> for StmtRef<'a> {
5030    fn from(node: &'a crate::StmtFor) -> Self {
5031        Self::For(node)
5032    }
5033}
5034
5035impl<'a> From<&'a crate::StmtWhile> for StmtRef<'a> {
5036    fn from(node: &'a crate::StmtWhile) -> Self {
5037        Self::While(node)
5038    }
5039}
5040
5041impl<'a> From<&'a crate::StmtIf> for StmtRef<'a> {
5042    fn from(node: &'a crate::StmtIf) -> Self {
5043        Self::If(node)
5044    }
5045}
5046
5047impl<'a> From<&'a crate::StmtWith> for StmtRef<'a> {
5048    fn from(node: &'a crate::StmtWith) -> Self {
5049        Self::With(node)
5050    }
5051}
5052
5053impl<'a> From<&'a crate::StmtMatch> for StmtRef<'a> {
5054    fn from(node: &'a crate::StmtMatch) -> Self {
5055        Self::Match(node)
5056    }
5057}
5058
5059impl<'a> From<&'a crate::StmtRaise> for StmtRef<'a> {
5060    fn from(node: &'a crate::StmtRaise) -> Self {
5061        Self::Raise(node)
5062    }
5063}
5064
5065impl<'a> From<&'a crate::StmtTry> for StmtRef<'a> {
5066    fn from(node: &'a crate::StmtTry) -> Self {
5067        Self::Try(node)
5068    }
5069}
5070
5071impl<'a> From<&'a crate::StmtAssert> for StmtRef<'a> {
5072    fn from(node: &'a crate::StmtAssert) -> Self {
5073        Self::Assert(node)
5074    }
5075}
5076
5077impl<'a> From<&'a crate::StmtImport> for StmtRef<'a> {
5078    fn from(node: &'a crate::StmtImport) -> Self {
5079        Self::Import(node)
5080    }
5081}
5082
5083impl<'a> From<&'a crate::StmtImportFrom> for StmtRef<'a> {
5084    fn from(node: &'a crate::StmtImportFrom) -> Self {
5085        Self::ImportFrom(node)
5086    }
5087}
5088
5089impl<'a> From<&'a crate::StmtGlobal> for StmtRef<'a> {
5090    fn from(node: &'a crate::StmtGlobal) -> Self {
5091        Self::Global(node)
5092    }
5093}
5094
5095impl<'a> From<&'a crate::StmtNonlocal> for StmtRef<'a> {
5096    fn from(node: &'a crate::StmtNonlocal) -> Self {
5097        Self::Nonlocal(node)
5098    }
5099}
5100
5101impl<'a> From<&'a crate::StmtExpr> for StmtRef<'a> {
5102    fn from(node: &'a crate::StmtExpr) -> Self {
5103        Self::Expr(node)
5104    }
5105}
5106
5107impl<'a> From<&'a crate::StmtPass> for StmtRef<'a> {
5108    fn from(node: &'a crate::StmtPass) -> Self {
5109        Self::Pass(node)
5110    }
5111}
5112
5113impl<'a> From<&'a crate::StmtBreak> for StmtRef<'a> {
5114    fn from(node: &'a crate::StmtBreak) -> Self {
5115        Self::Break(node)
5116    }
5117}
5118
5119impl<'a> From<&'a crate::StmtContinue> for StmtRef<'a> {
5120    fn from(node: &'a crate::StmtContinue) -> Self {
5121        Self::Continue(node)
5122    }
5123}
5124
5125impl<'a> From<&'a crate::StmtIpyEscapeCommand> for StmtRef<'a> {
5126    fn from(node: &'a crate::StmtIpyEscapeCommand) -> Self {
5127        Self::IpyEscapeCommand(node)
5128    }
5129}
5130
5131impl ruff_text_size::Ranged for StmtRef<'_> {
5132    fn range(&self) -> ruff_text_size::TextRange {
5133        match self {
5134            Self::FunctionDef(node) => node.range(),
5135            Self::ClassDef(node) => node.range(),
5136            Self::Return(node) => node.range(),
5137            Self::Delete(node) => node.range(),
5138            Self::TypeAlias(node) => node.range(),
5139            Self::Assign(node) => node.range(),
5140            Self::AugAssign(node) => node.range(),
5141            Self::AnnAssign(node) => node.range(),
5142            Self::For(node) => node.range(),
5143            Self::While(node) => node.range(),
5144            Self::If(node) => node.range(),
5145            Self::With(node) => node.range(),
5146            Self::Match(node) => node.range(),
5147            Self::Raise(node) => node.range(),
5148            Self::Try(node) => node.range(),
5149            Self::Assert(node) => node.range(),
5150            Self::Import(node) => node.range(),
5151            Self::ImportFrom(node) => node.range(),
5152            Self::Global(node) => node.range(),
5153            Self::Nonlocal(node) => node.range(),
5154            Self::Expr(node) => node.range(),
5155            Self::Pass(node) => node.range(),
5156            Self::Break(node) => node.range(),
5157            Self::Continue(node) => node.range(),
5158            Self::IpyEscapeCommand(node) => node.range(),
5159        }
5160    }
5161}
5162
5163impl crate::HasNodeIndex for StmtRef<'_> {
5164    fn node_index(&self) -> &crate::AtomicNodeIndex {
5165        match self {
5166            Self::FunctionDef(node) => node.node_index(),
5167            Self::ClassDef(node) => node.node_index(),
5168            Self::Return(node) => node.node_index(),
5169            Self::Delete(node) => node.node_index(),
5170            Self::TypeAlias(node) => node.node_index(),
5171            Self::Assign(node) => node.node_index(),
5172            Self::AugAssign(node) => node.node_index(),
5173            Self::AnnAssign(node) => node.node_index(),
5174            Self::For(node) => node.node_index(),
5175            Self::While(node) => node.node_index(),
5176            Self::If(node) => node.node_index(),
5177            Self::With(node) => node.node_index(),
5178            Self::Match(node) => node.node_index(),
5179            Self::Raise(node) => node.node_index(),
5180            Self::Try(node) => node.node_index(),
5181            Self::Assert(node) => node.node_index(),
5182            Self::Import(node) => node.node_index(),
5183            Self::ImportFrom(node) => node.node_index(),
5184            Self::Global(node) => node.node_index(),
5185            Self::Nonlocal(node) => node.node_index(),
5186            Self::Expr(node) => node.node_index(),
5187            Self::Pass(node) => node.node_index(),
5188            Self::Break(node) => node.node_index(),
5189            Self::Continue(node) => node.node_index(),
5190            Self::IpyEscapeCommand(node) => node.node_index(),
5191        }
5192    }
5193}
5194
5195/// See also [expr](https://docs.python.org/3/library/ast.html#ast.expr)
5196#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)]
5197#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
5198pub enum ExprRef<'a> {
5199    #[is(name = "bool_op_expr")]
5200    BoolOp(&'a crate::ExprBoolOp),
5201    #[is(name = "named_expr")]
5202    Named(&'a crate::ExprNamed),
5203    #[is(name = "bin_op_expr")]
5204    BinOp(&'a crate::ExprBinOp),
5205    #[is(name = "unary_op_expr")]
5206    UnaryOp(&'a crate::ExprUnaryOp),
5207    #[is(name = "lambda_expr")]
5208    Lambda(&'a crate::ExprLambda),
5209    #[is(name = "if_expr")]
5210    If(&'a crate::ExprIf),
5211    #[is(name = "dict_expr")]
5212    Dict(&'a crate::ExprDict),
5213    #[is(name = "set_expr")]
5214    Set(&'a crate::ExprSet),
5215    #[is(name = "list_comp_expr")]
5216    ListComp(&'a crate::ExprListComp),
5217    #[is(name = "set_comp_expr")]
5218    SetComp(&'a crate::ExprSetComp),
5219    #[is(name = "dict_comp_expr")]
5220    DictComp(&'a crate::ExprDictComp),
5221    #[is(name = "generator_expr")]
5222    Generator(&'a crate::ExprGenerator),
5223    #[is(name = "await_expr")]
5224    Await(&'a crate::ExprAwait),
5225    #[is(name = "yield_expr")]
5226    Yield(&'a crate::ExprYield),
5227    #[is(name = "yield_from_expr")]
5228    YieldFrom(&'a crate::ExprYieldFrom),
5229    #[is(name = "compare_expr")]
5230    Compare(&'a crate::ExprCompare),
5231    #[is(name = "call_expr")]
5232    Call(&'a crate::ExprCall),
5233    #[is(name = "f_string_expr")]
5234    FString(&'a crate::ExprFString),
5235    #[is(name = "t_string_expr")]
5236    TString(&'a crate::ExprTString),
5237    #[is(name = "string_literal_expr")]
5238    StringLiteral(&'a crate::ExprStringLiteral),
5239    #[is(name = "bytes_literal_expr")]
5240    BytesLiteral(&'a crate::ExprBytesLiteral),
5241    #[is(name = "number_literal_expr")]
5242    NumberLiteral(&'a crate::ExprNumberLiteral),
5243    #[is(name = "boolean_literal_expr")]
5244    BooleanLiteral(&'a crate::ExprBooleanLiteral),
5245    #[is(name = "none_literal_expr")]
5246    NoneLiteral(&'a crate::ExprNoneLiteral),
5247    #[is(name = "ellipsis_literal_expr")]
5248    EllipsisLiteral(&'a crate::ExprEllipsisLiteral),
5249    #[is(name = "attribute_expr")]
5250    Attribute(&'a crate::ExprAttribute),
5251    #[is(name = "subscript_expr")]
5252    Subscript(&'a crate::ExprSubscript),
5253    #[is(name = "starred_expr")]
5254    Starred(&'a crate::ExprStarred),
5255    #[is(name = "name_expr")]
5256    Name(&'a crate::ExprName),
5257    #[is(name = "list_expr")]
5258    List(&'a crate::ExprList),
5259    #[is(name = "tuple_expr")]
5260    Tuple(&'a crate::ExprTuple),
5261    #[is(name = "slice_expr")]
5262    Slice(&'a crate::ExprSlice),
5263    #[is(name = "ipy_escape_command_expr")]
5264    IpyEscapeCommand(&'a crate::ExprIpyEscapeCommand),
5265}
5266
5267impl<'a> From<&'a Expr> for ExprRef<'a> {
5268    fn from(node: &'a Expr) -> Self {
5269        match node {
5270            Expr::BoolOp(node) => ExprRef::BoolOp(node),
5271            Expr::Named(node) => ExprRef::Named(node),
5272            Expr::BinOp(node) => ExprRef::BinOp(node),
5273            Expr::UnaryOp(node) => ExprRef::UnaryOp(node),
5274            Expr::Lambda(node) => ExprRef::Lambda(node),
5275            Expr::If(node) => ExprRef::If(node),
5276            Expr::Dict(node) => ExprRef::Dict(node),
5277            Expr::Set(node) => ExprRef::Set(node),
5278            Expr::ListComp(node) => ExprRef::ListComp(node),
5279            Expr::SetComp(node) => ExprRef::SetComp(node),
5280            Expr::DictComp(node) => ExprRef::DictComp(node),
5281            Expr::Generator(node) => ExprRef::Generator(node),
5282            Expr::Await(node) => ExprRef::Await(node),
5283            Expr::Yield(node) => ExprRef::Yield(node),
5284            Expr::YieldFrom(node) => ExprRef::YieldFrom(node),
5285            Expr::Compare(node) => ExprRef::Compare(node),
5286            Expr::Call(node) => ExprRef::Call(node),
5287            Expr::FString(node) => ExprRef::FString(node),
5288            Expr::TString(node) => ExprRef::TString(node),
5289            Expr::StringLiteral(node) => ExprRef::StringLiteral(node),
5290            Expr::BytesLiteral(node) => ExprRef::BytesLiteral(node),
5291            Expr::NumberLiteral(node) => ExprRef::NumberLiteral(node),
5292            Expr::BooleanLiteral(node) => ExprRef::BooleanLiteral(node),
5293            Expr::NoneLiteral(node) => ExprRef::NoneLiteral(node),
5294            Expr::EllipsisLiteral(node) => ExprRef::EllipsisLiteral(node),
5295            Expr::Attribute(node) => ExprRef::Attribute(node),
5296            Expr::Subscript(node) => ExprRef::Subscript(node),
5297            Expr::Starred(node) => ExprRef::Starred(node),
5298            Expr::Name(node) => ExprRef::Name(node),
5299            Expr::List(node) => ExprRef::List(node),
5300            Expr::Tuple(node) => ExprRef::Tuple(node),
5301            Expr::Slice(node) => ExprRef::Slice(node),
5302            Expr::IpyEscapeCommand(node) => ExprRef::IpyEscapeCommand(node),
5303        }
5304    }
5305}
5306
5307impl<'a> From<&'a crate::ExprBoolOp> for ExprRef<'a> {
5308    fn from(node: &'a crate::ExprBoolOp) -> Self {
5309        Self::BoolOp(node)
5310    }
5311}
5312
5313impl<'a> From<&'a crate::ExprNamed> for ExprRef<'a> {
5314    fn from(node: &'a crate::ExprNamed) -> Self {
5315        Self::Named(node)
5316    }
5317}
5318
5319impl<'a> From<&'a crate::ExprBinOp> for ExprRef<'a> {
5320    fn from(node: &'a crate::ExprBinOp) -> Self {
5321        Self::BinOp(node)
5322    }
5323}
5324
5325impl<'a> From<&'a crate::ExprUnaryOp> for ExprRef<'a> {
5326    fn from(node: &'a crate::ExprUnaryOp) -> Self {
5327        Self::UnaryOp(node)
5328    }
5329}
5330
5331impl<'a> From<&'a crate::ExprLambda> for ExprRef<'a> {
5332    fn from(node: &'a crate::ExprLambda) -> Self {
5333        Self::Lambda(node)
5334    }
5335}
5336
5337impl<'a> From<&'a crate::ExprIf> for ExprRef<'a> {
5338    fn from(node: &'a crate::ExprIf) -> Self {
5339        Self::If(node)
5340    }
5341}
5342
5343impl<'a> From<&'a crate::ExprDict> for ExprRef<'a> {
5344    fn from(node: &'a crate::ExprDict) -> Self {
5345        Self::Dict(node)
5346    }
5347}
5348
5349impl<'a> From<&'a crate::ExprSet> for ExprRef<'a> {
5350    fn from(node: &'a crate::ExprSet) -> Self {
5351        Self::Set(node)
5352    }
5353}
5354
5355impl<'a> From<&'a crate::ExprListComp> for ExprRef<'a> {
5356    fn from(node: &'a crate::ExprListComp) -> Self {
5357        Self::ListComp(node)
5358    }
5359}
5360
5361impl<'a> From<&'a crate::ExprSetComp> for ExprRef<'a> {
5362    fn from(node: &'a crate::ExprSetComp) -> Self {
5363        Self::SetComp(node)
5364    }
5365}
5366
5367impl<'a> From<&'a crate::ExprDictComp> for ExprRef<'a> {
5368    fn from(node: &'a crate::ExprDictComp) -> Self {
5369        Self::DictComp(node)
5370    }
5371}
5372
5373impl<'a> From<&'a crate::ExprGenerator> for ExprRef<'a> {
5374    fn from(node: &'a crate::ExprGenerator) -> Self {
5375        Self::Generator(node)
5376    }
5377}
5378
5379impl<'a> From<&'a crate::ExprAwait> for ExprRef<'a> {
5380    fn from(node: &'a crate::ExprAwait) -> Self {
5381        Self::Await(node)
5382    }
5383}
5384
5385impl<'a> From<&'a crate::ExprYield> for ExprRef<'a> {
5386    fn from(node: &'a crate::ExprYield) -> Self {
5387        Self::Yield(node)
5388    }
5389}
5390
5391impl<'a> From<&'a crate::ExprYieldFrom> for ExprRef<'a> {
5392    fn from(node: &'a crate::ExprYieldFrom) -> Self {
5393        Self::YieldFrom(node)
5394    }
5395}
5396
5397impl<'a> From<&'a crate::ExprCompare> for ExprRef<'a> {
5398    fn from(node: &'a crate::ExprCompare) -> Self {
5399        Self::Compare(node)
5400    }
5401}
5402
5403impl<'a> From<&'a crate::ExprCall> for ExprRef<'a> {
5404    fn from(node: &'a crate::ExprCall) -> Self {
5405        Self::Call(node)
5406    }
5407}
5408
5409impl<'a> From<&'a crate::ExprFString> for ExprRef<'a> {
5410    fn from(node: &'a crate::ExprFString) -> Self {
5411        Self::FString(node)
5412    }
5413}
5414
5415impl<'a> From<&'a crate::ExprTString> for ExprRef<'a> {
5416    fn from(node: &'a crate::ExprTString) -> Self {
5417        Self::TString(node)
5418    }
5419}
5420
5421impl<'a> From<&'a crate::ExprStringLiteral> for ExprRef<'a> {
5422    fn from(node: &'a crate::ExprStringLiteral) -> Self {
5423        Self::StringLiteral(node)
5424    }
5425}
5426
5427impl<'a> From<&'a crate::ExprBytesLiteral> for ExprRef<'a> {
5428    fn from(node: &'a crate::ExprBytesLiteral) -> Self {
5429        Self::BytesLiteral(node)
5430    }
5431}
5432
5433impl<'a> From<&'a crate::ExprNumberLiteral> for ExprRef<'a> {
5434    fn from(node: &'a crate::ExprNumberLiteral) -> Self {
5435        Self::NumberLiteral(node)
5436    }
5437}
5438
5439impl<'a> From<&'a crate::ExprBooleanLiteral> for ExprRef<'a> {
5440    fn from(node: &'a crate::ExprBooleanLiteral) -> Self {
5441        Self::BooleanLiteral(node)
5442    }
5443}
5444
5445impl<'a> From<&'a crate::ExprNoneLiteral> for ExprRef<'a> {
5446    fn from(node: &'a crate::ExprNoneLiteral) -> Self {
5447        Self::NoneLiteral(node)
5448    }
5449}
5450
5451impl<'a> From<&'a crate::ExprEllipsisLiteral> for ExprRef<'a> {
5452    fn from(node: &'a crate::ExprEllipsisLiteral) -> Self {
5453        Self::EllipsisLiteral(node)
5454    }
5455}
5456
5457impl<'a> From<&'a crate::ExprAttribute> for ExprRef<'a> {
5458    fn from(node: &'a crate::ExprAttribute) -> Self {
5459        Self::Attribute(node)
5460    }
5461}
5462
5463impl<'a> From<&'a crate::ExprSubscript> for ExprRef<'a> {
5464    fn from(node: &'a crate::ExprSubscript) -> Self {
5465        Self::Subscript(node)
5466    }
5467}
5468
5469impl<'a> From<&'a crate::ExprStarred> for ExprRef<'a> {
5470    fn from(node: &'a crate::ExprStarred) -> Self {
5471        Self::Starred(node)
5472    }
5473}
5474
5475impl<'a> From<&'a crate::ExprName> for ExprRef<'a> {
5476    fn from(node: &'a crate::ExprName) -> Self {
5477        Self::Name(node)
5478    }
5479}
5480
5481impl<'a> From<&'a crate::ExprList> for ExprRef<'a> {
5482    fn from(node: &'a crate::ExprList) -> Self {
5483        Self::List(node)
5484    }
5485}
5486
5487impl<'a> From<&'a crate::ExprTuple> for ExprRef<'a> {
5488    fn from(node: &'a crate::ExprTuple) -> Self {
5489        Self::Tuple(node)
5490    }
5491}
5492
5493impl<'a> From<&'a crate::ExprSlice> for ExprRef<'a> {
5494    fn from(node: &'a crate::ExprSlice) -> Self {
5495        Self::Slice(node)
5496    }
5497}
5498
5499impl<'a> From<&'a crate::ExprIpyEscapeCommand> for ExprRef<'a> {
5500    fn from(node: &'a crate::ExprIpyEscapeCommand) -> Self {
5501        Self::IpyEscapeCommand(node)
5502    }
5503}
5504
5505impl ruff_text_size::Ranged for ExprRef<'_> {
5506    fn range(&self) -> ruff_text_size::TextRange {
5507        match self {
5508            Self::BoolOp(node) => node.range(),
5509            Self::Named(node) => node.range(),
5510            Self::BinOp(node) => node.range(),
5511            Self::UnaryOp(node) => node.range(),
5512            Self::Lambda(node) => node.range(),
5513            Self::If(node) => node.range(),
5514            Self::Dict(node) => node.range(),
5515            Self::Set(node) => node.range(),
5516            Self::ListComp(node) => node.range(),
5517            Self::SetComp(node) => node.range(),
5518            Self::DictComp(node) => node.range(),
5519            Self::Generator(node) => node.range(),
5520            Self::Await(node) => node.range(),
5521            Self::Yield(node) => node.range(),
5522            Self::YieldFrom(node) => node.range(),
5523            Self::Compare(node) => node.range(),
5524            Self::Call(node) => node.range(),
5525            Self::FString(node) => node.range(),
5526            Self::TString(node) => node.range(),
5527            Self::StringLiteral(node) => node.range(),
5528            Self::BytesLiteral(node) => node.range(),
5529            Self::NumberLiteral(node) => node.range(),
5530            Self::BooleanLiteral(node) => node.range(),
5531            Self::NoneLiteral(node) => node.range(),
5532            Self::EllipsisLiteral(node) => node.range(),
5533            Self::Attribute(node) => node.range(),
5534            Self::Subscript(node) => node.range(),
5535            Self::Starred(node) => node.range(),
5536            Self::Name(node) => node.range(),
5537            Self::List(node) => node.range(),
5538            Self::Tuple(node) => node.range(),
5539            Self::Slice(node) => node.range(),
5540            Self::IpyEscapeCommand(node) => node.range(),
5541        }
5542    }
5543}
5544
5545impl crate::HasNodeIndex for ExprRef<'_> {
5546    fn node_index(&self) -> &crate::AtomicNodeIndex {
5547        match self {
5548            Self::BoolOp(node) => node.node_index(),
5549            Self::Named(node) => node.node_index(),
5550            Self::BinOp(node) => node.node_index(),
5551            Self::UnaryOp(node) => node.node_index(),
5552            Self::Lambda(node) => node.node_index(),
5553            Self::If(node) => node.node_index(),
5554            Self::Dict(node) => node.node_index(),
5555            Self::Set(node) => node.node_index(),
5556            Self::ListComp(node) => node.node_index(),
5557            Self::SetComp(node) => node.node_index(),
5558            Self::DictComp(node) => node.node_index(),
5559            Self::Generator(node) => node.node_index(),
5560            Self::Await(node) => node.node_index(),
5561            Self::Yield(node) => node.node_index(),
5562            Self::YieldFrom(node) => node.node_index(),
5563            Self::Compare(node) => node.node_index(),
5564            Self::Call(node) => node.node_index(),
5565            Self::FString(node) => node.node_index(),
5566            Self::TString(node) => node.node_index(),
5567            Self::StringLiteral(node) => node.node_index(),
5568            Self::BytesLiteral(node) => node.node_index(),
5569            Self::NumberLiteral(node) => node.node_index(),
5570            Self::BooleanLiteral(node) => node.node_index(),
5571            Self::NoneLiteral(node) => node.node_index(),
5572            Self::EllipsisLiteral(node) => node.node_index(),
5573            Self::Attribute(node) => node.node_index(),
5574            Self::Subscript(node) => node.node_index(),
5575            Self::Starred(node) => node.node_index(),
5576            Self::Name(node) => node.node_index(),
5577            Self::List(node) => node.node_index(),
5578            Self::Tuple(node) => node.node_index(),
5579            Self::Slice(node) => node.node_index(),
5580            Self::IpyEscapeCommand(node) => node.node_index(),
5581        }
5582    }
5583}
5584
5585/// See also [excepthandler](https://docs.python.org/3/library/ast.html#ast.excepthandler)
5586#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)]
5587#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
5588pub enum ExceptHandlerRef<'a> {
5589    ExceptHandler(&'a crate::ExceptHandlerExceptHandler),
5590}
5591
5592impl<'a> From<&'a ExceptHandler> for ExceptHandlerRef<'a> {
5593    fn from(node: &'a ExceptHandler) -> Self {
5594        match node {
5595            ExceptHandler::ExceptHandler(node) => ExceptHandlerRef::ExceptHandler(node),
5596        }
5597    }
5598}
5599
5600impl<'a> From<&'a crate::ExceptHandlerExceptHandler> for ExceptHandlerRef<'a> {
5601    fn from(node: &'a crate::ExceptHandlerExceptHandler) -> Self {
5602        Self::ExceptHandler(node)
5603    }
5604}
5605
5606impl ruff_text_size::Ranged for ExceptHandlerRef<'_> {
5607    fn range(&self) -> ruff_text_size::TextRange {
5608        match self {
5609            Self::ExceptHandler(node) => node.range(),
5610        }
5611    }
5612}
5613
5614impl crate::HasNodeIndex for ExceptHandlerRef<'_> {
5615    fn node_index(&self) -> &crate::AtomicNodeIndex {
5616        match self {
5617            Self::ExceptHandler(node) => node.node_index(),
5618        }
5619    }
5620}
5621
5622#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)]
5623#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
5624pub enum InterpolatedStringElementRef<'a> {
5625    Interpolation(&'a crate::InterpolatedElement),
5626    Literal(&'a crate::InterpolatedStringLiteralElement),
5627}
5628
5629impl<'a> From<&'a InterpolatedStringElement> for InterpolatedStringElementRef<'a> {
5630    fn from(node: &'a InterpolatedStringElement) -> Self {
5631        match node {
5632            InterpolatedStringElement::Interpolation(node) => {
5633                InterpolatedStringElementRef::Interpolation(node)
5634            }
5635            InterpolatedStringElement::Literal(node) => InterpolatedStringElementRef::Literal(node),
5636        }
5637    }
5638}
5639
5640impl<'a> From<&'a crate::InterpolatedElement> for InterpolatedStringElementRef<'a> {
5641    fn from(node: &'a crate::InterpolatedElement) -> Self {
5642        Self::Interpolation(node)
5643    }
5644}
5645
5646impl<'a> From<&'a crate::InterpolatedStringLiteralElement> for InterpolatedStringElementRef<'a> {
5647    fn from(node: &'a crate::InterpolatedStringLiteralElement) -> Self {
5648        Self::Literal(node)
5649    }
5650}
5651
5652impl ruff_text_size::Ranged for InterpolatedStringElementRef<'_> {
5653    fn range(&self) -> ruff_text_size::TextRange {
5654        match self {
5655            Self::Interpolation(node) => node.range(),
5656            Self::Literal(node) => node.range(),
5657        }
5658    }
5659}
5660
5661impl crate::HasNodeIndex for InterpolatedStringElementRef<'_> {
5662    fn node_index(&self) -> &crate::AtomicNodeIndex {
5663        match self {
5664            Self::Interpolation(node) => node.node_index(),
5665            Self::Literal(node) => node.node_index(),
5666        }
5667    }
5668}
5669
5670/// See also [pattern](https://docs.python.org/3/library/ast.html#ast.pattern)
5671#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)]
5672#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
5673pub enum PatternRef<'a> {
5674    MatchValue(&'a crate::PatternMatchValue),
5675    MatchSingleton(&'a crate::PatternMatchSingleton),
5676    MatchSequence(&'a crate::PatternMatchSequence),
5677    MatchMapping(&'a crate::PatternMatchMapping),
5678    MatchClass(&'a crate::PatternMatchClass),
5679    MatchStar(&'a crate::PatternMatchStar),
5680    MatchAs(&'a crate::PatternMatchAs),
5681    MatchOr(&'a crate::PatternMatchOr),
5682}
5683
5684impl<'a> From<&'a Pattern> for PatternRef<'a> {
5685    fn from(node: &'a Pattern) -> Self {
5686        match node {
5687            Pattern::MatchValue(node) => PatternRef::MatchValue(node),
5688            Pattern::MatchSingleton(node) => PatternRef::MatchSingleton(node),
5689            Pattern::MatchSequence(node) => PatternRef::MatchSequence(node),
5690            Pattern::MatchMapping(node) => PatternRef::MatchMapping(node),
5691            Pattern::MatchClass(node) => PatternRef::MatchClass(node),
5692            Pattern::MatchStar(node) => PatternRef::MatchStar(node),
5693            Pattern::MatchAs(node) => PatternRef::MatchAs(node),
5694            Pattern::MatchOr(node) => PatternRef::MatchOr(node),
5695        }
5696    }
5697}
5698
5699impl<'a> From<&'a crate::PatternMatchValue> for PatternRef<'a> {
5700    fn from(node: &'a crate::PatternMatchValue) -> Self {
5701        Self::MatchValue(node)
5702    }
5703}
5704
5705impl<'a> From<&'a crate::PatternMatchSingleton> for PatternRef<'a> {
5706    fn from(node: &'a crate::PatternMatchSingleton) -> Self {
5707        Self::MatchSingleton(node)
5708    }
5709}
5710
5711impl<'a> From<&'a crate::PatternMatchSequence> for PatternRef<'a> {
5712    fn from(node: &'a crate::PatternMatchSequence) -> Self {
5713        Self::MatchSequence(node)
5714    }
5715}
5716
5717impl<'a> From<&'a crate::PatternMatchMapping> for PatternRef<'a> {
5718    fn from(node: &'a crate::PatternMatchMapping) -> Self {
5719        Self::MatchMapping(node)
5720    }
5721}
5722
5723impl<'a> From<&'a crate::PatternMatchClass> for PatternRef<'a> {
5724    fn from(node: &'a crate::PatternMatchClass) -> Self {
5725        Self::MatchClass(node)
5726    }
5727}
5728
5729impl<'a> From<&'a crate::PatternMatchStar> for PatternRef<'a> {
5730    fn from(node: &'a crate::PatternMatchStar) -> Self {
5731        Self::MatchStar(node)
5732    }
5733}
5734
5735impl<'a> From<&'a crate::PatternMatchAs> for PatternRef<'a> {
5736    fn from(node: &'a crate::PatternMatchAs) -> Self {
5737        Self::MatchAs(node)
5738    }
5739}
5740
5741impl<'a> From<&'a crate::PatternMatchOr> for PatternRef<'a> {
5742    fn from(node: &'a crate::PatternMatchOr) -> Self {
5743        Self::MatchOr(node)
5744    }
5745}
5746
5747impl ruff_text_size::Ranged for PatternRef<'_> {
5748    fn range(&self) -> ruff_text_size::TextRange {
5749        match self {
5750            Self::MatchValue(node) => node.range(),
5751            Self::MatchSingleton(node) => node.range(),
5752            Self::MatchSequence(node) => node.range(),
5753            Self::MatchMapping(node) => node.range(),
5754            Self::MatchClass(node) => node.range(),
5755            Self::MatchStar(node) => node.range(),
5756            Self::MatchAs(node) => node.range(),
5757            Self::MatchOr(node) => node.range(),
5758        }
5759    }
5760}
5761
5762impl crate::HasNodeIndex for PatternRef<'_> {
5763    fn node_index(&self) -> &crate::AtomicNodeIndex {
5764        match self {
5765            Self::MatchValue(node) => node.node_index(),
5766            Self::MatchSingleton(node) => node.node_index(),
5767            Self::MatchSequence(node) => node.node_index(),
5768            Self::MatchMapping(node) => node.node_index(),
5769            Self::MatchClass(node) => node.node_index(),
5770            Self::MatchStar(node) => node.node_index(),
5771            Self::MatchAs(node) => node.node_index(),
5772            Self::MatchOr(node) => node.node_index(),
5773        }
5774    }
5775}
5776
5777/// See also [type_param](https://docs.python.org/3/library/ast.html#ast.type_param)
5778#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)]
5779#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
5780pub enum TypeParamRef<'a> {
5781    TypeVar(&'a crate::TypeParamTypeVar),
5782    TypeVarTuple(&'a crate::TypeParamTypeVarTuple),
5783    ParamSpec(&'a crate::TypeParamParamSpec),
5784}
5785
5786impl<'a> From<&'a TypeParam> for TypeParamRef<'a> {
5787    fn from(node: &'a TypeParam) -> Self {
5788        match node {
5789            TypeParam::TypeVar(node) => TypeParamRef::TypeVar(node),
5790            TypeParam::TypeVarTuple(node) => TypeParamRef::TypeVarTuple(node),
5791            TypeParam::ParamSpec(node) => TypeParamRef::ParamSpec(node),
5792        }
5793    }
5794}
5795
5796impl<'a> From<&'a crate::TypeParamTypeVar> for TypeParamRef<'a> {
5797    fn from(node: &'a crate::TypeParamTypeVar) -> Self {
5798        Self::TypeVar(node)
5799    }
5800}
5801
5802impl<'a> From<&'a crate::TypeParamTypeVarTuple> for TypeParamRef<'a> {
5803    fn from(node: &'a crate::TypeParamTypeVarTuple) -> Self {
5804        Self::TypeVarTuple(node)
5805    }
5806}
5807
5808impl<'a> From<&'a crate::TypeParamParamSpec> for TypeParamRef<'a> {
5809    fn from(node: &'a crate::TypeParamParamSpec) -> Self {
5810        Self::ParamSpec(node)
5811    }
5812}
5813
5814impl ruff_text_size::Ranged for TypeParamRef<'_> {
5815    fn range(&self) -> ruff_text_size::TextRange {
5816        match self {
5817            Self::TypeVar(node) => node.range(),
5818            Self::TypeVarTuple(node) => node.range(),
5819            Self::ParamSpec(node) => node.range(),
5820        }
5821    }
5822}
5823
5824impl crate::HasNodeIndex for TypeParamRef<'_> {
5825    fn node_index(&self) -> &crate::AtomicNodeIndex {
5826        match self {
5827            Self::TypeVar(node) => node.node_index(),
5828            Self::TypeVarTuple(node) => node.node_index(),
5829            Self::ParamSpec(node) => node.node_index(),
5830        }
5831    }
5832}
5833
5834/// A flattened enumeration of all AST nodes.
5835#[derive(Copy, Clone, Debug, is_macro::Is, PartialEq)]
5836#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
5837pub enum AnyNodeRef<'a> {
5838    ModModule(&'a crate::ModModule),
5839    ModExpression(&'a crate::ModExpression),
5840    StmtFunctionDef(&'a crate::StmtFunctionDef),
5841    StmtClassDef(&'a crate::StmtClassDef),
5842    StmtReturn(&'a crate::StmtReturn),
5843    StmtDelete(&'a crate::StmtDelete),
5844    StmtTypeAlias(&'a crate::StmtTypeAlias),
5845    StmtAssign(&'a crate::StmtAssign),
5846    StmtAugAssign(&'a crate::StmtAugAssign),
5847    StmtAnnAssign(&'a crate::StmtAnnAssign),
5848    StmtFor(&'a crate::StmtFor),
5849    StmtWhile(&'a crate::StmtWhile),
5850    StmtIf(&'a crate::StmtIf),
5851    StmtWith(&'a crate::StmtWith),
5852    StmtMatch(&'a crate::StmtMatch),
5853    StmtRaise(&'a crate::StmtRaise),
5854    StmtTry(&'a crate::StmtTry),
5855    StmtAssert(&'a crate::StmtAssert),
5856    StmtImport(&'a crate::StmtImport),
5857    StmtImportFrom(&'a crate::StmtImportFrom),
5858    StmtGlobal(&'a crate::StmtGlobal),
5859    StmtNonlocal(&'a crate::StmtNonlocal),
5860    StmtExpr(&'a crate::StmtExpr),
5861    StmtPass(&'a crate::StmtPass),
5862    StmtBreak(&'a crate::StmtBreak),
5863    StmtContinue(&'a crate::StmtContinue),
5864    StmtIpyEscapeCommand(&'a crate::StmtIpyEscapeCommand),
5865    ExprBoolOp(&'a crate::ExprBoolOp),
5866    ExprNamed(&'a crate::ExprNamed),
5867    ExprBinOp(&'a crate::ExprBinOp),
5868    ExprUnaryOp(&'a crate::ExprUnaryOp),
5869    ExprLambda(&'a crate::ExprLambda),
5870    ExprIf(&'a crate::ExprIf),
5871    ExprDict(&'a crate::ExprDict),
5872    ExprSet(&'a crate::ExprSet),
5873    ExprListComp(&'a crate::ExprListComp),
5874    ExprSetComp(&'a crate::ExprSetComp),
5875    ExprDictComp(&'a crate::ExprDictComp),
5876    ExprGenerator(&'a crate::ExprGenerator),
5877    ExprAwait(&'a crate::ExprAwait),
5878    ExprYield(&'a crate::ExprYield),
5879    ExprYieldFrom(&'a crate::ExprYieldFrom),
5880    ExprCompare(&'a crate::ExprCompare),
5881    ExprCall(&'a crate::ExprCall),
5882    ExprFString(&'a crate::ExprFString),
5883    ExprTString(&'a crate::ExprTString),
5884    ExprStringLiteral(&'a crate::ExprStringLiteral),
5885    ExprBytesLiteral(&'a crate::ExprBytesLiteral),
5886    ExprNumberLiteral(&'a crate::ExprNumberLiteral),
5887    ExprBooleanLiteral(&'a crate::ExprBooleanLiteral),
5888    ExprNoneLiteral(&'a crate::ExprNoneLiteral),
5889    ExprEllipsisLiteral(&'a crate::ExprEllipsisLiteral),
5890    ExprAttribute(&'a crate::ExprAttribute),
5891    ExprSubscript(&'a crate::ExprSubscript),
5892    ExprStarred(&'a crate::ExprStarred),
5893    ExprName(&'a crate::ExprName),
5894    ExprList(&'a crate::ExprList),
5895    ExprTuple(&'a crate::ExprTuple),
5896    ExprSlice(&'a crate::ExprSlice),
5897    ExprIpyEscapeCommand(&'a crate::ExprIpyEscapeCommand),
5898    ExceptHandlerExceptHandler(&'a crate::ExceptHandlerExceptHandler),
5899    InterpolatedElement(&'a crate::InterpolatedElement),
5900    InterpolatedStringLiteralElement(&'a crate::InterpolatedStringLiteralElement),
5901    PatternMatchValue(&'a crate::PatternMatchValue),
5902    PatternMatchSingleton(&'a crate::PatternMatchSingleton),
5903    PatternMatchSequence(&'a crate::PatternMatchSequence),
5904    PatternMatchMapping(&'a crate::PatternMatchMapping),
5905    PatternMatchClass(&'a crate::PatternMatchClass),
5906    PatternMatchStar(&'a crate::PatternMatchStar),
5907    PatternMatchAs(&'a crate::PatternMatchAs),
5908    PatternMatchOr(&'a crate::PatternMatchOr),
5909    TypeParamTypeVar(&'a crate::TypeParamTypeVar),
5910    TypeParamTypeVarTuple(&'a crate::TypeParamTypeVarTuple),
5911    TypeParamParamSpec(&'a crate::TypeParamParamSpec),
5912    InterpolatedStringFormatSpec(&'a crate::InterpolatedStringFormatSpec),
5913    PatternArguments(&'a crate::PatternArguments),
5914    PatternKeyword(&'a crate::PatternKeyword),
5915    Comprehension(&'a crate::Comprehension),
5916    Arguments(&'a crate::Arguments),
5917    Parameters(&'a crate::Parameters),
5918    Parameter(&'a crate::Parameter),
5919    ParameterWithDefault(&'a crate::ParameterWithDefault),
5920    Keyword(&'a crate::Keyword),
5921    Alias(&'a crate::Alias),
5922    WithItem(&'a crate::WithItem),
5923    MatchCase(&'a crate::MatchCase),
5924    Decorator(&'a crate::Decorator),
5925    ElifElseClause(&'a crate::ElifElseClause),
5926    TypeParams(&'a crate::TypeParams),
5927    FString(&'a crate::FString),
5928    TString(&'a crate::TString),
5929    StringLiteral(&'a crate::StringLiteral),
5930    BytesLiteral(&'a crate::BytesLiteral),
5931    Identifier(&'a crate::Identifier),
5932}
5933
5934impl<'a> From<&'a Mod> for AnyNodeRef<'a> {
5935    fn from(node: &'a Mod) -> AnyNodeRef<'a> {
5936        match node {
5937            Mod::Module(node) => AnyNodeRef::ModModule(node),
5938            Mod::Expression(node) => AnyNodeRef::ModExpression(node),
5939        }
5940    }
5941}
5942
5943impl<'a> From<ModRef<'a>> for AnyNodeRef<'a> {
5944    fn from(node: ModRef<'a>) -> AnyNodeRef<'a> {
5945        match node {
5946            ModRef::Module(node) => AnyNodeRef::ModModule(node),
5947            ModRef::Expression(node) => AnyNodeRef::ModExpression(node),
5948        }
5949    }
5950}
5951
5952impl<'a> AnyNodeRef<'a> {
5953    pub fn as_mod_ref(self) -> Option<ModRef<'a>> {
5954        match self {
5955            Self::ModModule(node) => Some(ModRef::Module(node)),
5956            Self::ModExpression(node) => Some(ModRef::Expression(node)),
5957
5958            _ => None,
5959        }
5960    }
5961}
5962
5963impl<'a> From<&'a Stmt> for AnyNodeRef<'a> {
5964    fn from(node: &'a Stmt) -> AnyNodeRef<'a> {
5965        match node {
5966            Stmt::FunctionDef(node) => AnyNodeRef::StmtFunctionDef(node),
5967            Stmt::ClassDef(node) => AnyNodeRef::StmtClassDef(node),
5968            Stmt::Return(node) => AnyNodeRef::StmtReturn(node),
5969            Stmt::Delete(node) => AnyNodeRef::StmtDelete(node),
5970            Stmt::TypeAlias(node) => AnyNodeRef::StmtTypeAlias(node),
5971            Stmt::Assign(node) => AnyNodeRef::StmtAssign(node),
5972            Stmt::AugAssign(node) => AnyNodeRef::StmtAugAssign(node),
5973            Stmt::AnnAssign(node) => AnyNodeRef::StmtAnnAssign(node),
5974            Stmt::For(node) => AnyNodeRef::StmtFor(node),
5975            Stmt::While(node) => AnyNodeRef::StmtWhile(node),
5976            Stmt::If(node) => AnyNodeRef::StmtIf(node),
5977            Stmt::With(node) => AnyNodeRef::StmtWith(node),
5978            Stmt::Match(node) => AnyNodeRef::StmtMatch(node),
5979            Stmt::Raise(node) => AnyNodeRef::StmtRaise(node),
5980            Stmt::Try(node) => AnyNodeRef::StmtTry(node),
5981            Stmt::Assert(node) => AnyNodeRef::StmtAssert(node),
5982            Stmt::Import(node) => AnyNodeRef::StmtImport(node),
5983            Stmt::ImportFrom(node) => AnyNodeRef::StmtImportFrom(node),
5984            Stmt::Global(node) => AnyNodeRef::StmtGlobal(node),
5985            Stmt::Nonlocal(node) => AnyNodeRef::StmtNonlocal(node),
5986            Stmt::Expr(node) => AnyNodeRef::StmtExpr(node),
5987            Stmt::Pass(node) => AnyNodeRef::StmtPass(node),
5988            Stmt::Break(node) => AnyNodeRef::StmtBreak(node),
5989            Stmt::Continue(node) => AnyNodeRef::StmtContinue(node),
5990            Stmt::IpyEscapeCommand(node) => AnyNodeRef::StmtIpyEscapeCommand(node),
5991        }
5992    }
5993}
5994
5995impl<'a> From<StmtRef<'a>> for AnyNodeRef<'a> {
5996    fn from(node: StmtRef<'a>) -> AnyNodeRef<'a> {
5997        match node {
5998            StmtRef::FunctionDef(node) => AnyNodeRef::StmtFunctionDef(node),
5999            StmtRef::ClassDef(node) => AnyNodeRef::StmtClassDef(node),
6000            StmtRef::Return(node) => AnyNodeRef::StmtReturn(node),
6001            StmtRef::Delete(node) => AnyNodeRef::StmtDelete(node),
6002            StmtRef::TypeAlias(node) => AnyNodeRef::StmtTypeAlias(node),
6003            StmtRef::Assign(node) => AnyNodeRef::StmtAssign(node),
6004            StmtRef::AugAssign(node) => AnyNodeRef::StmtAugAssign(node),
6005            StmtRef::AnnAssign(node) => AnyNodeRef::StmtAnnAssign(node),
6006            StmtRef::For(node) => AnyNodeRef::StmtFor(node),
6007            StmtRef::While(node) => AnyNodeRef::StmtWhile(node),
6008            StmtRef::If(node) => AnyNodeRef::StmtIf(node),
6009            StmtRef::With(node) => AnyNodeRef::StmtWith(node),
6010            StmtRef::Match(node) => AnyNodeRef::StmtMatch(node),
6011            StmtRef::Raise(node) => AnyNodeRef::StmtRaise(node),
6012            StmtRef::Try(node) => AnyNodeRef::StmtTry(node),
6013            StmtRef::Assert(node) => AnyNodeRef::StmtAssert(node),
6014            StmtRef::Import(node) => AnyNodeRef::StmtImport(node),
6015            StmtRef::ImportFrom(node) => AnyNodeRef::StmtImportFrom(node),
6016            StmtRef::Global(node) => AnyNodeRef::StmtGlobal(node),
6017            StmtRef::Nonlocal(node) => AnyNodeRef::StmtNonlocal(node),
6018            StmtRef::Expr(node) => AnyNodeRef::StmtExpr(node),
6019            StmtRef::Pass(node) => AnyNodeRef::StmtPass(node),
6020            StmtRef::Break(node) => AnyNodeRef::StmtBreak(node),
6021            StmtRef::Continue(node) => AnyNodeRef::StmtContinue(node),
6022            StmtRef::IpyEscapeCommand(node) => AnyNodeRef::StmtIpyEscapeCommand(node),
6023        }
6024    }
6025}
6026
6027impl<'a> AnyNodeRef<'a> {
6028    pub fn as_stmt_ref(self) -> Option<StmtRef<'a>> {
6029        match self {
6030            Self::StmtFunctionDef(node) => Some(StmtRef::FunctionDef(node)),
6031            Self::StmtClassDef(node) => Some(StmtRef::ClassDef(node)),
6032            Self::StmtReturn(node) => Some(StmtRef::Return(node)),
6033            Self::StmtDelete(node) => Some(StmtRef::Delete(node)),
6034            Self::StmtTypeAlias(node) => Some(StmtRef::TypeAlias(node)),
6035            Self::StmtAssign(node) => Some(StmtRef::Assign(node)),
6036            Self::StmtAugAssign(node) => Some(StmtRef::AugAssign(node)),
6037            Self::StmtAnnAssign(node) => Some(StmtRef::AnnAssign(node)),
6038            Self::StmtFor(node) => Some(StmtRef::For(node)),
6039            Self::StmtWhile(node) => Some(StmtRef::While(node)),
6040            Self::StmtIf(node) => Some(StmtRef::If(node)),
6041            Self::StmtWith(node) => Some(StmtRef::With(node)),
6042            Self::StmtMatch(node) => Some(StmtRef::Match(node)),
6043            Self::StmtRaise(node) => Some(StmtRef::Raise(node)),
6044            Self::StmtTry(node) => Some(StmtRef::Try(node)),
6045            Self::StmtAssert(node) => Some(StmtRef::Assert(node)),
6046            Self::StmtImport(node) => Some(StmtRef::Import(node)),
6047            Self::StmtImportFrom(node) => Some(StmtRef::ImportFrom(node)),
6048            Self::StmtGlobal(node) => Some(StmtRef::Global(node)),
6049            Self::StmtNonlocal(node) => Some(StmtRef::Nonlocal(node)),
6050            Self::StmtExpr(node) => Some(StmtRef::Expr(node)),
6051            Self::StmtPass(node) => Some(StmtRef::Pass(node)),
6052            Self::StmtBreak(node) => Some(StmtRef::Break(node)),
6053            Self::StmtContinue(node) => Some(StmtRef::Continue(node)),
6054            Self::StmtIpyEscapeCommand(node) => Some(StmtRef::IpyEscapeCommand(node)),
6055
6056            _ => None,
6057        }
6058    }
6059}
6060
6061impl<'a> From<&'a Expr> for AnyNodeRef<'a> {
6062    fn from(node: &'a Expr) -> AnyNodeRef<'a> {
6063        match node {
6064            Expr::BoolOp(node) => AnyNodeRef::ExprBoolOp(node),
6065            Expr::Named(node) => AnyNodeRef::ExprNamed(node),
6066            Expr::BinOp(node) => AnyNodeRef::ExprBinOp(node),
6067            Expr::UnaryOp(node) => AnyNodeRef::ExprUnaryOp(node),
6068            Expr::Lambda(node) => AnyNodeRef::ExprLambda(node),
6069            Expr::If(node) => AnyNodeRef::ExprIf(node),
6070            Expr::Dict(node) => AnyNodeRef::ExprDict(node),
6071            Expr::Set(node) => AnyNodeRef::ExprSet(node),
6072            Expr::ListComp(node) => AnyNodeRef::ExprListComp(node),
6073            Expr::SetComp(node) => AnyNodeRef::ExprSetComp(node),
6074            Expr::DictComp(node) => AnyNodeRef::ExprDictComp(node),
6075            Expr::Generator(node) => AnyNodeRef::ExprGenerator(node),
6076            Expr::Await(node) => AnyNodeRef::ExprAwait(node),
6077            Expr::Yield(node) => AnyNodeRef::ExprYield(node),
6078            Expr::YieldFrom(node) => AnyNodeRef::ExprYieldFrom(node),
6079            Expr::Compare(node) => AnyNodeRef::ExprCompare(node),
6080            Expr::Call(node) => AnyNodeRef::ExprCall(node),
6081            Expr::FString(node) => AnyNodeRef::ExprFString(node),
6082            Expr::TString(node) => AnyNodeRef::ExprTString(node),
6083            Expr::StringLiteral(node) => AnyNodeRef::ExprStringLiteral(node),
6084            Expr::BytesLiteral(node) => AnyNodeRef::ExprBytesLiteral(node),
6085            Expr::NumberLiteral(node) => AnyNodeRef::ExprNumberLiteral(node),
6086            Expr::BooleanLiteral(node) => AnyNodeRef::ExprBooleanLiteral(node),
6087            Expr::NoneLiteral(node) => AnyNodeRef::ExprNoneLiteral(node),
6088            Expr::EllipsisLiteral(node) => AnyNodeRef::ExprEllipsisLiteral(node),
6089            Expr::Attribute(node) => AnyNodeRef::ExprAttribute(node),
6090            Expr::Subscript(node) => AnyNodeRef::ExprSubscript(node),
6091            Expr::Starred(node) => AnyNodeRef::ExprStarred(node),
6092            Expr::Name(node) => AnyNodeRef::ExprName(node),
6093            Expr::List(node) => AnyNodeRef::ExprList(node),
6094            Expr::Tuple(node) => AnyNodeRef::ExprTuple(node),
6095            Expr::Slice(node) => AnyNodeRef::ExprSlice(node),
6096            Expr::IpyEscapeCommand(node) => AnyNodeRef::ExprIpyEscapeCommand(node),
6097        }
6098    }
6099}
6100
6101impl<'a> From<ExprRef<'a>> for AnyNodeRef<'a> {
6102    fn from(node: ExprRef<'a>) -> AnyNodeRef<'a> {
6103        match node {
6104            ExprRef::BoolOp(node) => AnyNodeRef::ExprBoolOp(node),
6105            ExprRef::Named(node) => AnyNodeRef::ExprNamed(node),
6106            ExprRef::BinOp(node) => AnyNodeRef::ExprBinOp(node),
6107            ExprRef::UnaryOp(node) => AnyNodeRef::ExprUnaryOp(node),
6108            ExprRef::Lambda(node) => AnyNodeRef::ExprLambda(node),
6109            ExprRef::If(node) => AnyNodeRef::ExprIf(node),
6110            ExprRef::Dict(node) => AnyNodeRef::ExprDict(node),
6111            ExprRef::Set(node) => AnyNodeRef::ExprSet(node),
6112            ExprRef::ListComp(node) => AnyNodeRef::ExprListComp(node),
6113            ExprRef::SetComp(node) => AnyNodeRef::ExprSetComp(node),
6114            ExprRef::DictComp(node) => AnyNodeRef::ExprDictComp(node),
6115            ExprRef::Generator(node) => AnyNodeRef::ExprGenerator(node),
6116            ExprRef::Await(node) => AnyNodeRef::ExprAwait(node),
6117            ExprRef::Yield(node) => AnyNodeRef::ExprYield(node),
6118            ExprRef::YieldFrom(node) => AnyNodeRef::ExprYieldFrom(node),
6119            ExprRef::Compare(node) => AnyNodeRef::ExprCompare(node),
6120            ExprRef::Call(node) => AnyNodeRef::ExprCall(node),
6121            ExprRef::FString(node) => AnyNodeRef::ExprFString(node),
6122            ExprRef::TString(node) => AnyNodeRef::ExprTString(node),
6123            ExprRef::StringLiteral(node) => AnyNodeRef::ExprStringLiteral(node),
6124            ExprRef::BytesLiteral(node) => AnyNodeRef::ExprBytesLiteral(node),
6125            ExprRef::NumberLiteral(node) => AnyNodeRef::ExprNumberLiteral(node),
6126            ExprRef::BooleanLiteral(node) => AnyNodeRef::ExprBooleanLiteral(node),
6127            ExprRef::NoneLiteral(node) => AnyNodeRef::ExprNoneLiteral(node),
6128            ExprRef::EllipsisLiteral(node) => AnyNodeRef::ExprEllipsisLiteral(node),
6129            ExprRef::Attribute(node) => AnyNodeRef::ExprAttribute(node),
6130            ExprRef::Subscript(node) => AnyNodeRef::ExprSubscript(node),
6131            ExprRef::Starred(node) => AnyNodeRef::ExprStarred(node),
6132            ExprRef::Name(node) => AnyNodeRef::ExprName(node),
6133            ExprRef::List(node) => AnyNodeRef::ExprList(node),
6134            ExprRef::Tuple(node) => AnyNodeRef::ExprTuple(node),
6135            ExprRef::Slice(node) => AnyNodeRef::ExprSlice(node),
6136            ExprRef::IpyEscapeCommand(node) => AnyNodeRef::ExprIpyEscapeCommand(node),
6137        }
6138    }
6139}
6140
6141impl<'a> AnyNodeRef<'a> {
6142    pub fn as_expr_ref(self) -> Option<ExprRef<'a>> {
6143        match self {
6144            Self::ExprBoolOp(node) => Some(ExprRef::BoolOp(node)),
6145            Self::ExprNamed(node) => Some(ExprRef::Named(node)),
6146            Self::ExprBinOp(node) => Some(ExprRef::BinOp(node)),
6147            Self::ExprUnaryOp(node) => Some(ExprRef::UnaryOp(node)),
6148            Self::ExprLambda(node) => Some(ExprRef::Lambda(node)),
6149            Self::ExprIf(node) => Some(ExprRef::If(node)),
6150            Self::ExprDict(node) => Some(ExprRef::Dict(node)),
6151            Self::ExprSet(node) => Some(ExprRef::Set(node)),
6152            Self::ExprListComp(node) => Some(ExprRef::ListComp(node)),
6153            Self::ExprSetComp(node) => Some(ExprRef::SetComp(node)),
6154            Self::ExprDictComp(node) => Some(ExprRef::DictComp(node)),
6155            Self::ExprGenerator(node) => Some(ExprRef::Generator(node)),
6156            Self::ExprAwait(node) => Some(ExprRef::Await(node)),
6157            Self::ExprYield(node) => Some(ExprRef::Yield(node)),
6158            Self::ExprYieldFrom(node) => Some(ExprRef::YieldFrom(node)),
6159            Self::ExprCompare(node) => Some(ExprRef::Compare(node)),
6160            Self::ExprCall(node) => Some(ExprRef::Call(node)),
6161            Self::ExprFString(node) => Some(ExprRef::FString(node)),
6162            Self::ExprTString(node) => Some(ExprRef::TString(node)),
6163            Self::ExprStringLiteral(node) => Some(ExprRef::StringLiteral(node)),
6164            Self::ExprBytesLiteral(node) => Some(ExprRef::BytesLiteral(node)),
6165            Self::ExprNumberLiteral(node) => Some(ExprRef::NumberLiteral(node)),
6166            Self::ExprBooleanLiteral(node) => Some(ExprRef::BooleanLiteral(node)),
6167            Self::ExprNoneLiteral(node) => Some(ExprRef::NoneLiteral(node)),
6168            Self::ExprEllipsisLiteral(node) => Some(ExprRef::EllipsisLiteral(node)),
6169            Self::ExprAttribute(node) => Some(ExprRef::Attribute(node)),
6170            Self::ExprSubscript(node) => Some(ExprRef::Subscript(node)),
6171            Self::ExprStarred(node) => Some(ExprRef::Starred(node)),
6172            Self::ExprName(node) => Some(ExprRef::Name(node)),
6173            Self::ExprList(node) => Some(ExprRef::List(node)),
6174            Self::ExprTuple(node) => Some(ExprRef::Tuple(node)),
6175            Self::ExprSlice(node) => Some(ExprRef::Slice(node)),
6176            Self::ExprIpyEscapeCommand(node) => Some(ExprRef::IpyEscapeCommand(node)),
6177
6178            _ => None,
6179        }
6180    }
6181}
6182
6183impl<'a> From<&'a ExceptHandler> for AnyNodeRef<'a> {
6184    fn from(node: &'a ExceptHandler) -> AnyNodeRef<'a> {
6185        match node {
6186            ExceptHandler::ExceptHandler(node) => AnyNodeRef::ExceptHandlerExceptHandler(node),
6187        }
6188    }
6189}
6190
6191impl<'a> From<ExceptHandlerRef<'a>> for AnyNodeRef<'a> {
6192    fn from(node: ExceptHandlerRef<'a>) -> AnyNodeRef<'a> {
6193        match node {
6194            ExceptHandlerRef::ExceptHandler(node) => AnyNodeRef::ExceptHandlerExceptHandler(node),
6195        }
6196    }
6197}
6198
6199impl<'a> AnyNodeRef<'a> {
6200    pub fn as_except_handler_ref(self) -> Option<ExceptHandlerRef<'a>> {
6201        match self {
6202            Self::ExceptHandlerExceptHandler(node) => Some(ExceptHandlerRef::ExceptHandler(node)),
6203
6204            _ => None,
6205        }
6206    }
6207}
6208
6209impl<'a> From<&'a InterpolatedStringElement> for AnyNodeRef<'a> {
6210    fn from(node: &'a InterpolatedStringElement) -> AnyNodeRef<'a> {
6211        match node {
6212            InterpolatedStringElement::Interpolation(node) => AnyNodeRef::InterpolatedElement(node),
6213            InterpolatedStringElement::Literal(node) => {
6214                AnyNodeRef::InterpolatedStringLiteralElement(node)
6215            }
6216        }
6217    }
6218}
6219
6220impl<'a> From<InterpolatedStringElementRef<'a>> for AnyNodeRef<'a> {
6221    fn from(node: InterpolatedStringElementRef<'a>) -> AnyNodeRef<'a> {
6222        match node {
6223            InterpolatedStringElementRef::Interpolation(node) => {
6224                AnyNodeRef::InterpolatedElement(node)
6225            }
6226            InterpolatedStringElementRef::Literal(node) => {
6227                AnyNodeRef::InterpolatedStringLiteralElement(node)
6228            }
6229        }
6230    }
6231}
6232
6233impl<'a> AnyNodeRef<'a> {
6234    pub fn as_interpolated_string_element_ref(self) -> Option<InterpolatedStringElementRef<'a>> {
6235        match self {
6236            Self::InterpolatedElement(node) => {
6237                Some(InterpolatedStringElementRef::Interpolation(node))
6238            }
6239            Self::InterpolatedStringLiteralElement(node) => {
6240                Some(InterpolatedStringElementRef::Literal(node))
6241            }
6242
6243            _ => None,
6244        }
6245    }
6246}
6247
6248impl<'a> From<&'a Pattern> for AnyNodeRef<'a> {
6249    fn from(node: &'a Pattern) -> AnyNodeRef<'a> {
6250        match node {
6251            Pattern::MatchValue(node) => AnyNodeRef::PatternMatchValue(node),
6252            Pattern::MatchSingleton(node) => AnyNodeRef::PatternMatchSingleton(node),
6253            Pattern::MatchSequence(node) => AnyNodeRef::PatternMatchSequence(node),
6254            Pattern::MatchMapping(node) => AnyNodeRef::PatternMatchMapping(node),
6255            Pattern::MatchClass(node) => AnyNodeRef::PatternMatchClass(node),
6256            Pattern::MatchStar(node) => AnyNodeRef::PatternMatchStar(node),
6257            Pattern::MatchAs(node) => AnyNodeRef::PatternMatchAs(node),
6258            Pattern::MatchOr(node) => AnyNodeRef::PatternMatchOr(node),
6259        }
6260    }
6261}
6262
6263impl<'a> From<PatternRef<'a>> for AnyNodeRef<'a> {
6264    fn from(node: PatternRef<'a>) -> AnyNodeRef<'a> {
6265        match node {
6266            PatternRef::MatchValue(node) => AnyNodeRef::PatternMatchValue(node),
6267            PatternRef::MatchSingleton(node) => AnyNodeRef::PatternMatchSingleton(node),
6268            PatternRef::MatchSequence(node) => AnyNodeRef::PatternMatchSequence(node),
6269            PatternRef::MatchMapping(node) => AnyNodeRef::PatternMatchMapping(node),
6270            PatternRef::MatchClass(node) => AnyNodeRef::PatternMatchClass(node),
6271            PatternRef::MatchStar(node) => AnyNodeRef::PatternMatchStar(node),
6272            PatternRef::MatchAs(node) => AnyNodeRef::PatternMatchAs(node),
6273            PatternRef::MatchOr(node) => AnyNodeRef::PatternMatchOr(node),
6274        }
6275    }
6276}
6277
6278impl<'a> AnyNodeRef<'a> {
6279    pub fn as_pattern_ref(self) -> Option<PatternRef<'a>> {
6280        match self {
6281            Self::PatternMatchValue(node) => Some(PatternRef::MatchValue(node)),
6282            Self::PatternMatchSingleton(node) => Some(PatternRef::MatchSingleton(node)),
6283            Self::PatternMatchSequence(node) => Some(PatternRef::MatchSequence(node)),
6284            Self::PatternMatchMapping(node) => Some(PatternRef::MatchMapping(node)),
6285            Self::PatternMatchClass(node) => Some(PatternRef::MatchClass(node)),
6286            Self::PatternMatchStar(node) => Some(PatternRef::MatchStar(node)),
6287            Self::PatternMatchAs(node) => Some(PatternRef::MatchAs(node)),
6288            Self::PatternMatchOr(node) => Some(PatternRef::MatchOr(node)),
6289
6290            _ => None,
6291        }
6292    }
6293}
6294
6295impl<'a> From<&'a TypeParam> for AnyNodeRef<'a> {
6296    fn from(node: &'a TypeParam) -> AnyNodeRef<'a> {
6297        match node {
6298            TypeParam::TypeVar(node) => AnyNodeRef::TypeParamTypeVar(node),
6299            TypeParam::TypeVarTuple(node) => AnyNodeRef::TypeParamTypeVarTuple(node),
6300            TypeParam::ParamSpec(node) => AnyNodeRef::TypeParamParamSpec(node),
6301        }
6302    }
6303}
6304
6305impl<'a> From<TypeParamRef<'a>> for AnyNodeRef<'a> {
6306    fn from(node: TypeParamRef<'a>) -> AnyNodeRef<'a> {
6307        match node {
6308            TypeParamRef::TypeVar(node) => AnyNodeRef::TypeParamTypeVar(node),
6309            TypeParamRef::TypeVarTuple(node) => AnyNodeRef::TypeParamTypeVarTuple(node),
6310            TypeParamRef::ParamSpec(node) => AnyNodeRef::TypeParamParamSpec(node),
6311        }
6312    }
6313}
6314
6315impl<'a> AnyNodeRef<'a> {
6316    pub fn as_type_param_ref(self) -> Option<TypeParamRef<'a>> {
6317        match self {
6318            Self::TypeParamTypeVar(node) => Some(TypeParamRef::TypeVar(node)),
6319            Self::TypeParamTypeVarTuple(node) => Some(TypeParamRef::TypeVarTuple(node)),
6320            Self::TypeParamParamSpec(node) => Some(TypeParamRef::ParamSpec(node)),
6321
6322            _ => None,
6323        }
6324    }
6325}
6326
6327impl<'a> From<&'a crate::ModModule> for AnyNodeRef<'a> {
6328    fn from(node: &'a crate::ModModule) -> AnyNodeRef<'a> {
6329        AnyNodeRef::ModModule(node)
6330    }
6331}
6332
6333impl<'a> From<&'a crate::ModExpression> for AnyNodeRef<'a> {
6334    fn from(node: &'a crate::ModExpression) -> AnyNodeRef<'a> {
6335        AnyNodeRef::ModExpression(node)
6336    }
6337}
6338
6339impl<'a> From<&'a crate::StmtFunctionDef> for AnyNodeRef<'a> {
6340    fn from(node: &'a crate::StmtFunctionDef) -> AnyNodeRef<'a> {
6341        AnyNodeRef::StmtFunctionDef(node)
6342    }
6343}
6344
6345impl<'a> From<&'a crate::StmtClassDef> for AnyNodeRef<'a> {
6346    fn from(node: &'a crate::StmtClassDef) -> AnyNodeRef<'a> {
6347        AnyNodeRef::StmtClassDef(node)
6348    }
6349}
6350
6351impl<'a> From<&'a crate::StmtReturn> for AnyNodeRef<'a> {
6352    fn from(node: &'a crate::StmtReturn) -> AnyNodeRef<'a> {
6353        AnyNodeRef::StmtReturn(node)
6354    }
6355}
6356
6357impl<'a> From<&'a crate::StmtDelete> for AnyNodeRef<'a> {
6358    fn from(node: &'a crate::StmtDelete) -> AnyNodeRef<'a> {
6359        AnyNodeRef::StmtDelete(node)
6360    }
6361}
6362
6363impl<'a> From<&'a crate::StmtTypeAlias> for AnyNodeRef<'a> {
6364    fn from(node: &'a crate::StmtTypeAlias) -> AnyNodeRef<'a> {
6365        AnyNodeRef::StmtTypeAlias(node)
6366    }
6367}
6368
6369impl<'a> From<&'a crate::StmtAssign> for AnyNodeRef<'a> {
6370    fn from(node: &'a crate::StmtAssign) -> AnyNodeRef<'a> {
6371        AnyNodeRef::StmtAssign(node)
6372    }
6373}
6374
6375impl<'a> From<&'a crate::StmtAugAssign> for AnyNodeRef<'a> {
6376    fn from(node: &'a crate::StmtAugAssign) -> AnyNodeRef<'a> {
6377        AnyNodeRef::StmtAugAssign(node)
6378    }
6379}
6380
6381impl<'a> From<&'a crate::StmtAnnAssign> for AnyNodeRef<'a> {
6382    fn from(node: &'a crate::StmtAnnAssign) -> AnyNodeRef<'a> {
6383        AnyNodeRef::StmtAnnAssign(node)
6384    }
6385}
6386
6387impl<'a> From<&'a crate::StmtFor> for AnyNodeRef<'a> {
6388    fn from(node: &'a crate::StmtFor) -> AnyNodeRef<'a> {
6389        AnyNodeRef::StmtFor(node)
6390    }
6391}
6392
6393impl<'a> From<&'a crate::StmtWhile> for AnyNodeRef<'a> {
6394    fn from(node: &'a crate::StmtWhile) -> AnyNodeRef<'a> {
6395        AnyNodeRef::StmtWhile(node)
6396    }
6397}
6398
6399impl<'a> From<&'a crate::StmtIf> for AnyNodeRef<'a> {
6400    fn from(node: &'a crate::StmtIf) -> AnyNodeRef<'a> {
6401        AnyNodeRef::StmtIf(node)
6402    }
6403}
6404
6405impl<'a> From<&'a crate::StmtWith> for AnyNodeRef<'a> {
6406    fn from(node: &'a crate::StmtWith) -> AnyNodeRef<'a> {
6407        AnyNodeRef::StmtWith(node)
6408    }
6409}
6410
6411impl<'a> From<&'a crate::StmtMatch> for AnyNodeRef<'a> {
6412    fn from(node: &'a crate::StmtMatch) -> AnyNodeRef<'a> {
6413        AnyNodeRef::StmtMatch(node)
6414    }
6415}
6416
6417impl<'a> From<&'a crate::StmtRaise> for AnyNodeRef<'a> {
6418    fn from(node: &'a crate::StmtRaise) -> AnyNodeRef<'a> {
6419        AnyNodeRef::StmtRaise(node)
6420    }
6421}
6422
6423impl<'a> From<&'a crate::StmtTry> for AnyNodeRef<'a> {
6424    fn from(node: &'a crate::StmtTry) -> AnyNodeRef<'a> {
6425        AnyNodeRef::StmtTry(node)
6426    }
6427}
6428
6429impl<'a> From<&'a crate::StmtAssert> for AnyNodeRef<'a> {
6430    fn from(node: &'a crate::StmtAssert) -> AnyNodeRef<'a> {
6431        AnyNodeRef::StmtAssert(node)
6432    }
6433}
6434
6435impl<'a> From<&'a crate::StmtImport> for AnyNodeRef<'a> {
6436    fn from(node: &'a crate::StmtImport) -> AnyNodeRef<'a> {
6437        AnyNodeRef::StmtImport(node)
6438    }
6439}
6440
6441impl<'a> From<&'a crate::StmtImportFrom> for AnyNodeRef<'a> {
6442    fn from(node: &'a crate::StmtImportFrom) -> AnyNodeRef<'a> {
6443        AnyNodeRef::StmtImportFrom(node)
6444    }
6445}
6446
6447impl<'a> From<&'a crate::StmtGlobal> for AnyNodeRef<'a> {
6448    fn from(node: &'a crate::StmtGlobal) -> AnyNodeRef<'a> {
6449        AnyNodeRef::StmtGlobal(node)
6450    }
6451}
6452
6453impl<'a> From<&'a crate::StmtNonlocal> for AnyNodeRef<'a> {
6454    fn from(node: &'a crate::StmtNonlocal) -> AnyNodeRef<'a> {
6455        AnyNodeRef::StmtNonlocal(node)
6456    }
6457}
6458
6459impl<'a> From<&'a crate::StmtExpr> for AnyNodeRef<'a> {
6460    fn from(node: &'a crate::StmtExpr) -> AnyNodeRef<'a> {
6461        AnyNodeRef::StmtExpr(node)
6462    }
6463}
6464
6465impl<'a> From<&'a crate::StmtPass> for AnyNodeRef<'a> {
6466    fn from(node: &'a crate::StmtPass) -> AnyNodeRef<'a> {
6467        AnyNodeRef::StmtPass(node)
6468    }
6469}
6470
6471impl<'a> From<&'a crate::StmtBreak> for AnyNodeRef<'a> {
6472    fn from(node: &'a crate::StmtBreak) -> AnyNodeRef<'a> {
6473        AnyNodeRef::StmtBreak(node)
6474    }
6475}
6476
6477impl<'a> From<&'a crate::StmtContinue> for AnyNodeRef<'a> {
6478    fn from(node: &'a crate::StmtContinue) -> AnyNodeRef<'a> {
6479        AnyNodeRef::StmtContinue(node)
6480    }
6481}
6482
6483impl<'a> From<&'a crate::StmtIpyEscapeCommand> for AnyNodeRef<'a> {
6484    fn from(node: &'a crate::StmtIpyEscapeCommand) -> AnyNodeRef<'a> {
6485        AnyNodeRef::StmtIpyEscapeCommand(node)
6486    }
6487}
6488
6489impl<'a> From<&'a crate::ExprBoolOp> for AnyNodeRef<'a> {
6490    fn from(node: &'a crate::ExprBoolOp) -> AnyNodeRef<'a> {
6491        AnyNodeRef::ExprBoolOp(node)
6492    }
6493}
6494
6495impl<'a> From<&'a crate::ExprNamed> for AnyNodeRef<'a> {
6496    fn from(node: &'a crate::ExprNamed) -> AnyNodeRef<'a> {
6497        AnyNodeRef::ExprNamed(node)
6498    }
6499}
6500
6501impl<'a> From<&'a crate::ExprBinOp> for AnyNodeRef<'a> {
6502    fn from(node: &'a crate::ExprBinOp) -> AnyNodeRef<'a> {
6503        AnyNodeRef::ExprBinOp(node)
6504    }
6505}
6506
6507impl<'a> From<&'a crate::ExprUnaryOp> for AnyNodeRef<'a> {
6508    fn from(node: &'a crate::ExprUnaryOp) -> AnyNodeRef<'a> {
6509        AnyNodeRef::ExprUnaryOp(node)
6510    }
6511}
6512
6513impl<'a> From<&'a crate::ExprLambda> for AnyNodeRef<'a> {
6514    fn from(node: &'a crate::ExprLambda) -> AnyNodeRef<'a> {
6515        AnyNodeRef::ExprLambda(node)
6516    }
6517}
6518
6519impl<'a> From<&'a crate::ExprIf> for AnyNodeRef<'a> {
6520    fn from(node: &'a crate::ExprIf) -> AnyNodeRef<'a> {
6521        AnyNodeRef::ExprIf(node)
6522    }
6523}
6524
6525impl<'a> From<&'a crate::ExprDict> for AnyNodeRef<'a> {
6526    fn from(node: &'a crate::ExprDict) -> AnyNodeRef<'a> {
6527        AnyNodeRef::ExprDict(node)
6528    }
6529}
6530
6531impl<'a> From<&'a crate::ExprSet> for AnyNodeRef<'a> {
6532    fn from(node: &'a crate::ExprSet) -> AnyNodeRef<'a> {
6533        AnyNodeRef::ExprSet(node)
6534    }
6535}
6536
6537impl<'a> From<&'a crate::ExprListComp> for AnyNodeRef<'a> {
6538    fn from(node: &'a crate::ExprListComp) -> AnyNodeRef<'a> {
6539        AnyNodeRef::ExprListComp(node)
6540    }
6541}
6542
6543impl<'a> From<&'a crate::ExprSetComp> for AnyNodeRef<'a> {
6544    fn from(node: &'a crate::ExprSetComp) -> AnyNodeRef<'a> {
6545        AnyNodeRef::ExprSetComp(node)
6546    }
6547}
6548
6549impl<'a> From<&'a crate::ExprDictComp> for AnyNodeRef<'a> {
6550    fn from(node: &'a crate::ExprDictComp) -> AnyNodeRef<'a> {
6551        AnyNodeRef::ExprDictComp(node)
6552    }
6553}
6554
6555impl<'a> From<&'a crate::ExprGenerator> for AnyNodeRef<'a> {
6556    fn from(node: &'a crate::ExprGenerator) -> AnyNodeRef<'a> {
6557        AnyNodeRef::ExprGenerator(node)
6558    }
6559}
6560
6561impl<'a> From<&'a crate::ExprAwait> for AnyNodeRef<'a> {
6562    fn from(node: &'a crate::ExprAwait) -> AnyNodeRef<'a> {
6563        AnyNodeRef::ExprAwait(node)
6564    }
6565}
6566
6567impl<'a> From<&'a crate::ExprYield> for AnyNodeRef<'a> {
6568    fn from(node: &'a crate::ExprYield) -> AnyNodeRef<'a> {
6569        AnyNodeRef::ExprYield(node)
6570    }
6571}
6572
6573impl<'a> From<&'a crate::ExprYieldFrom> for AnyNodeRef<'a> {
6574    fn from(node: &'a crate::ExprYieldFrom) -> AnyNodeRef<'a> {
6575        AnyNodeRef::ExprYieldFrom(node)
6576    }
6577}
6578
6579impl<'a> From<&'a crate::ExprCompare> for AnyNodeRef<'a> {
6580    fn from(node: &'a crate::ExprCompare) -> AnyNodeRef<'a> {
6581        AnyNodeRef::ExprCompare(node)
6582    }
6583}
6584
6585impl<'a> From<&'a crate::ExprCall> for AnyNodeRef<'a> {
6586    fn from(node: &'a crate::ExprCall) -> AnyNodeRef<'a> {
6587        AnyNodeRef::ExprCall(node)
6588    }
6589}
6590
6591impl<'a> From<&'a crate::ExprFString> for AnyNodeRef<'a> {
6592    fn from(node: &'a crate::ExprFString) -> AnyNodeRef<'a> {
6593        AnyNodeRef::ExprFString(node)
6594    }
6595}
6596
6597impl<'a> From<&'a crate::ExprTString> for AnyNodeRef<'a> {
6598    fn from(node: &'a crate::ExprTString) -> AnyNodeRef<'a> {
6599        AnyNodeRef::ExprTString(node)
6600    }
6601}
6602
6603impl<'a> From<&'a crate::ExprStringLiteral> for AnyNodeRef<'a> {
6604    fn from(node: &'a crate::ExprStringLiteral) -> AnyNodeRef<'a> {
6605        AnyNodeRef::ExprStringLiteral(node)
6606    }
6607}
6608
6609impl<'a> From<&'a crate::ExprBytesLiteral> for AnyNodeRef<'a> {
6610    fn from(node: &'a crate::ExprBytesLiteral) -> AnyNodeRef<'a> {
6611        AnyNodeRef::ExprBytesLiteral(node)
6612    }
6613}
6614
6615impl<'a> From<&'a crate::ExprNumberLiteral> for AnyNodeRef<'a> {
6616    fn from(node: &'a crate::ExprNumberLiteral) -> AnyNodeRef<'a> {
6617        AnyNodeRef::ExprNumberLiteral(node)
6618    }
6619}
6620
6621impl<'a> From<&'a crate::ExprBooleanLiteral> for AnyNodeRef<'a> {
6622    fn from(node: &'a crate::ExprBooleanLiteral) -> AnyNodeRef<'a> {
6623        AnyNodeRef::ExprBooleanLiteral(node)
6624    }
6625}
6626
6627impl<'a> From<&'a crate::ExprNoneLiteral> for AnyNodeRef<'a> {
6628    fn from(node: &'a crate::ExprNoneLiteral) -> AnyNodeRef<'a> {
6629        AnyNodeRef::ExprNoneLiteral(node)
6630    }
6631}
6632
6633impl<'a> From<&'a crate::ExprEllipsisLiteral> for AnyNodeRef<'a> {
6634    fn from(node: &'a crate::ExprEllipsisLiteral) -> AnyNodeRef<'a> {
6635        AnyNodeRef::ExprEllipsisLiteral(node)
6636    }
6637}
6638
6639impl<'a> From<&'a crate::ExprAttribute> for AnyNodeRef<'a> {
6640    fn from(node: &'a crate::ExprAttribute) -> AnyNodeRef<'a> {
6641        AnyNodeRef::ExprAttribute(node)
6642    }
6643}
6644
6645impl<'a> From<&'a crate::ExprSubscript> for AnyNodeRef<'a> {
6646    fn from(node: &'a crate::ExprSubscript) -> AnyNodeRef<'a> {
6647        AnyNodeRef::ExprSubscript(node)
6648    }
6649}
6650
6651impl<'a> From<&'a crate::ExprStarred> for AnyNodeRef<'a> {
6652    fn from(node: &'a crate::ExprStarred) -> AnyNodeRef<'a> {
6653        AnyNodeRef::ExprStarred(node)
6654    }
6655}
6656
6657impl<'a> From<&'a crate::ExprName> for AnyNodeRef<'a> {
6658    fn from(node: &'a crate::ExprName) -> AnyNodeRef<'a> {
6659        AnyNodeRef::ExprName(node)
6660    }
6661}
6662
6663impl<'a> From<&'a crate::ExprList> for AnyNodeRef<'a> {
6664    fn from(node: &'a crate::ExprList) -> AnyNodeRef<'a> {
6665        AnyNodeRef::ExprList(node)
6666    }
6667}
6668
6669impl<'a> From<&'a crate::ExprTuple> for AnyNodeRef<'a> {
6670    fn from(node: &'a crate::ExprTuple) -> AnyNodeRef<'a> {
6671        AnyNodeRef::ExprTuple(node)
6672    }
6673}
6674
6675impl<'a> From<&'a crate::ExprSlice> for AnyNodeRef<'a> {
6676    fn from(node: &'a crate::ExprSlice) -> AnyNodeRef<'a> {
6677        AnyNodeRef::ExprSlice(node)
6678    }
6679}
6680
6681impl<'a> From<&'a crate::ExprIpyEscapeCommand> for AnyNodeRef<'a> {
6682    fn from(node: &'a crate::ExprIpyEscapeCommand) -> AnyNodeRef<'a> {
6683        AnyNodeRef::ExprIpyEscapeCommand(node)
6684    }
6685}
6686
6687impl<'a> From<&'a crate::ExceptHandlerExceptHandler> for AnyNodeRef<'a> {
6688    fn from(node: &'a crate::ExceptHandlerExceptHandler) -> AnyNodeRef<'a> {
6689        AnyNodeRef::ExceptHandlerExceptHandler(node)
6690    }
6691}
6692
6693impl<'a> From<&'a crate::InterpolatedElement> for AnyNodeRef<'a> {
6694    fn from(node: &'a crate::InterpolatedElement) -> AnyNodeRef<'a> {
6695        AnyNodeRef::InterpolatedElement(node)
6696    }
6697}
6698
6699impl<'a> From<&'a crate::InterpolatedStringLiteralElement> for AnyNodeRef<'a> {
6700    fn from(node: &'a crate::InterpolatedStringLiteralElement) -> AnyNodeRef<'a> {
6701        AnyNodeRef::InterpolatedStringLiteralElement(node)
6702    }
6703}
6704
6705impl<'a> From<&'a crate::PatternMatchValue> for AnyNodeRef<'a> {
6706    fn from(node: &'a crate::PatternMatchValue) -> AnyNodeRef<'a> {
6707        AnyNodeRef::PatternMatchValue(node)
6708    }
6709}
6710
6711impl<'a> From<&'a crate::PatternMatchSingleton> for AnyNodeRef<'a> {
6712    fn from(node: &'a crate::PatternMatchSingleton) -> AnyNodeRef<'a> {
6713        AnyNodeRef::PatternMatchSingleton(node)
6714    }
6715}
6716
6717impl<'a> From<&'a crate::PatternMatchSequence> for AnyNodeRef<'a> {
6718    fn from(node: &'a crate::PatternMatchSequence) -> AnyNodeRef<'a> {
6719        AnyNodeRef::PatternMatchSequence(node)
6720    }
6721}
6722
6723impl<'a> From<&'a crate::PatternMatchMapping> for AnyNodeRef<'a> {
6724    fn from(node: &'a crate::PatternMatchMapping) -> AnyNodeRef<'a> {
6725        AnyNodeRef::PatternMatchMapping(node)
6726    }
6727}
6728
6729impl<'a> From<&'a crate::PatternMatchClass> for AnyNodeRef<'a> {
6730    fn from(node: &'a crate::PatternMatchClass) -> AnyNodeRef<'a> {
6731        AnyNodeRef::PatternMatchClass(node)
6732    }
6733}
6734
6735impl<'a> From<&'a crate::PatternMatchStar> for AnyNodeRef<'a> {
6736    fn from(node: &'a crate::PatternMatchStar) -> AnyNodeRef<'a> {
6737        AnyNodeRef::PatternMatchStar(node)
6738    }
6739}
6740
6741impl<'a> From<&'a crate::PatternMatchAs> for AnyNodeRef<'a> {
6742    fn from(node: &'a crate::PatternMatchAs) -> AnyNodeRef<'a> {
6743        AnyNodeRef::PatternMatchAs(node)
6744    }
6745}
6746
6747impl<'a> From<&'a crate::PatternMatchOr> for AnyNodeRef<'a> {
6748    fn from(node: &'a crate::PatternMatchOr) -> AnyNodeRef<'a> {
6749        AnyNodeRef::PatternMatchOr(node)
6750    }
6751}
6752
6753impl<'a> From<&'a crate::TypeParamTypeVar> for AnyNodeRef<'a> {
6754    fn from(node: &'a crate::TypeParamTypeVar) -> AnyNodeRef<'a> {
6755        AnyNodeRef::TypeParamTypeVar(node)
6756    }
6757}
6758
6759impl<'a> From<&'a crate::TypeParamTypeVarTuple> for AnyNodeRef<'a> {
6760    fn from(node: &'a crate::TypeParamTypeVarTuple) -> AnyNodeRef<'a> {
6761        AnyNodeRef::TypeParamTypeVarTuple(node)
6762    }
6763}
6764
6765impl<'a> From<&'a crate::TypeParamParamSpec> for AnyNodeRef<'a> {
6766    fn from(node: &'a crate::TypeParamParamSpec) -> AnyNodeRef<'a> {
6767        AnyNodeRef::TypeParamParamSpec(node)
6768    }
6769}
6770
6771impl<'a> From<&'a crate::InterpolatedStringFormatSpec> for AnyNodeRef<'a> {
6772    fn from(node: &'a crate::InterpolatedStringFormatSpec) -> AnyNodeRef<'a> {
6773        AnyNodeRef::InterpolatedStringFormatSpec(node)
6774    }
6775}
6776
6777impl<'a> From<&'a crate::PatternArguments> for AnyNodeRef<'a> {
6778    fn from(node: &'a crate::PatternArguments) -> AnyNodeRef<'a> {
6779        AnyNodeRef::PatternArguments(node)
6780    }
6781}
6782
6783impl<'a> From<&'a crate::PatternKeyword> for AnyNodeRef<'a> {
6784    fn from(node: &'a crate::PatternKeyword) -> AnyNodeRef<'a> {
6785        AnyNodeRef::PatternKeyword(node)
6786    }
6787}
6788
6789impl<'a> From<&'a crate::Comprehension> for AnyNodeRef<'a> {
6790    fn from(node: &'a crate::Comprehension) -> AnyNodeRef<'a> {
6791        AnyNodeRef::Comprehension(node)
6792    }
6793}
6794
6795impl<'a> From<&'a crate::Arguments> for AnyNodeRef<'a> {
6796    fn from(node: &'a crate::Arguments) -> AnyNodeRef<'a> {
6797        AnyNodeRef::Arguments(node)
6798    }
6799}
6800
6801impl<'a> From<&'a crate::Parameters> for AnyNodeRef<'a> {
6802    fn from(node: &'a crate::Parameters) -> AnyNodeRef<'a> {
6803        AnyNodeRef::Parameters(node)
6804    }
6805}
6806
6807impl<'a> From<&'a crate::Parameter> for AnyNodeRef<'a> {
6808    fn from(node: &'a crate::Parameter) -> AnyNodeRef<'a> {
6809        AnyNodeRef::Parameter(node)
6810    }
6811}
6812
6813impl<'a> From<&'a crate::ParameterWithDefault> for AnyNodeRef<'a> {
6814    fn from(node: &'a crate::ParameterWithDefault) -> AnyNodeRef<'a> {
6815        AnyNodeRef::ParameterWithDefault(node)
6816    }
6817}
6818
6819impl<'a> From<&'a crate::Keyword> for AnyNodeRef<'a> {
6820    fn from(node: &'a crate::Keyword) -> AnyNodeRef<'a> {
6821        AnyNodeRef::Keyword(node)
6822    }
6823}
6824
6825impl<'a> From<&'a crate::Alias> for AnyNodeRef<'a> {
6826    fn from(node: &'a crate::Alias) -> AnyNodeRef<'a> {
6827        AnyNodeRef::Alias(node)
6828    }
6829}
6830
6831impl<'a> From<&'a crate::WithItem> for AnyNodeRef<'a> {
6832    fn from(node: &'a crate::WithItem) -> AnyNodeRef<'a> {
6833        AnyNodeRef::WithItem(node)
6834    }
6835}
6836
6837impl<'a> From<&'a crate::MatchCase> for AnyNodeRef<'a> {
6838    fn from(node: &'a crate::MatchCase) -> AnyNodeRef<'a> {
6839        AnyNodeRef::MatchCase(node)
6840    }
6841}
6842
6843impl<'a> From<&'a crate::Decorator> for AnyNodeRef<'a> {
6844    fn from(node: &'a crate::Decorator) -> AnyNodeRef<'a> {
6845        AnyNodeRef::Decorator(node)
6846    }
6847}
6848
6849impl<'a> From<&'a crate::ElifElseClause> for AnyNodeRef<'a> {
6850    fn from(node: &'a crate::ElifElseClause) -> AnyNodeRef<'a> {
6851        AnyNodeRef::ElifElseClause(node)
6852    }
6853}
6854
6855impl<'a> From<&'a crate::TypeParams> for AnyNodeRef<'a> {
6856    fn from(node: &'a crate::TypeParams) -> AnyNodeRef<'a> {
6857        AnyNodeRef::TypeParams(node)
6858    }
6859}
6860
6861impl<'a> From<&'a crate::FString> for AnyNodeRef<'a> {
6862    fn from(node: &'a crate::FString) -> AnyNodeRef<'a> {
6863        AnyNodeRef::FString(node)
6864    }
6865}
6866
6867impl<'a> From<&'a crate::TString> for AnyNodeRef<'a> {
6868    fn from(node: &'a crate::TString) -> AnyNodeRef<'a> {
6869        AnyNodeRef::TString(node)
6870    }
6871}
6872
6873impl<'a> From<&'a crate::StringLiteral> for AnyNodeRef<'a> {
6874    fn from(node: &'a crate::StringLiteral) -> AnyNodeRef<'a> {
6875        AnyNodeRef::StringLiteral(node)
6876    }
6877}
6878
6879impl<'a> From<&'a crate::BytesLiteral> for AnyNodeRef<'a> {
6880    fn from(node: &'a crate::BytesLiteral) -> AnyNodeRef<'a> {
6881        AnyNodeRef::BytesLiteral(node)
6882    }
6883}
6884
6885impl<'a> From<&'a crate::Identifier> for AnyNodeRef<'a> {
6886    fn from(node: &'a crate::Identifier) -> AnyNodeRef<'a> {
6887        AnyNodeRef::Identifier(node)
6888    }
6889}
6890
6891impl ruff_text_size::Ranged for AnyNodeRef<'_> {
6892    fn range(&self) -> ruff_text_size::TextRange {
6893        match self {
6894            AnyNodeRef::ModModule(node) => node.range(),
6895            AnyNodeRef::ModExpression(node) => node.range(),
6896            AnyNodeRef::StmtFunctionDef(node) => node.range(),
6897            AnyNodeRef::StmtClassDef(node) => node.range(),
6898            AnyNodeRef::StmtReturn(node) => node.range(),
6899            AnyNodeRef::StmtDelete(node) => node.range(),
6900            AnyNodeRef::StmtTypeAlias(node) => node.range(),
6901            AnyNodeRef::StmtAssign(node) => node.range(),
6902            AnyNodeRef::StmtAugAssign(node) => node.range(),
6903            AnyNodeRef::StmtAnnAssign(node) => node.range(),
6904            AnyNodeRef::StmtFor(node) => node.range(),
6905            AnyNodeRef::StmtWhile(node) => node.range(),
6906            AnyNodeRef::StmtIf(node) => node.range(),
6907            AnyNodeRef::StmtWith(node) => node.range(),
6908            AnyNodeRef::StmtMatch(node) => node.range(),
6909            AnyNodeRef::StmtRaise(node) => node.range(),
6910            AnyNodeRef::StmtTry(node) => node.range(),
6911            AnyNodeRef::StmtAssert(node) => node.range(),
6912            AnyNodeRef::StmtImport(node) => node.range(),
6913            AnyNodeRef::StmtImportFrom(node) => node.range(),
6914            AnyNodeRef::StmtGlobal(node) => node.range(),
6915            AnyNodeRef::StmtNonlocal(node) => node.range(),
6916            AnyNodeRef::StmtExpr(node) => node.range(),
6917            AnyNodeRef::StmtPass(node) => node.range(),
6918            AnyNodeRef::StmtBreak(node) => node.range(),
6919            AnyNodeRef::StmtContinue(node) => node.range(),
6920            AnyNodeRef::StmtIpyEscapeCommand(node) => node.range(),
6921            AnyNodeRef::ExprBoolOp(node) => node.range(),
6922            AnyNodeRef::ExprNamed(node) => node.range(),
6923            AnyNodeRef::ExprBinOp(node) => node.range(),
6924            AnyNodeRef::ExprUnaryOp(node) => node.range(),
6925            AnyNodeRef::ExprLambda(node) => node.range(),
6926            AnyNodeRef::ExprIf(node) => node.range(),
6927            AnyNodeRef::ExprDict(node) => node.range(),
6928            AnyNodeRef::ExprSet(node) => node.range(),
6929            AnyNodeRef::ExprListComp(node) => node.range(),
6930            AnyNodeRef::ExprSetComp(node) => node.range(),
6931            AnyNodeRef::ExprDictComp(node) => node.range(),
6932            AnyNodeRef::ExprGenerator(node) => node.range(),
6933            AnyNodeRef::ExprAwait(node) => node.range(),
6934            AnyNodeRef::ExprYield(node) => node.range(),
6935            AnyNodeRef::ExprYieldFrom(node) => node.range(),
6936            AnyNodeRef::ExprCompare(node) => node.range(),
6937            AnyNodeRef::ExprCall(node) => node.range(),
6938            AnyNodeRef::ExprFString(node) => node.range(),
6939            AnyNodeRef::ExprTString(node) => node.range(),
6940            AnyNodeRef::ExprStringLiteral(node) => node.range(),
6941            AnyNodeRef::ExprBytesLiteral(node) => node.range(),
6942            AnyNodeRef::ExprNumberLiteral(node) => node.range(),
6943            AnyNodeRef::ExprBooleanLiteral(node) => node.range(),
6944            AnyNodeRef::ExprNoneLiteral(node) => node.range(),
6945            AnyNodeRef::ExprEllipsisLiteral(node) => node.range(),
6946            AnyNodeRef::ExprAttribute(node) => node.range(),
6947            AnyNodeRef::ExprSubscript(node) => node.range(),
6948            AnyNodeRef::ExprStarred(node) => node.range(),
6949            AnyNodeRef::ExprName(node) => node.range(),
6950            AnyNodeRef::ExprList(node) => node.range(),
6951            AnyNodeRef::ExprTuple(node) => node.range(),
6952            AnyNodeRef::ExprSlice(node) => node.range(),
6953            AnyNodeRef::ExprIpyEscapeCommand(node) => node.range(),
6954            AnyNodeRef::ExceptHandlerExceptHandler(node) => node.range(),
6955            AnyNodeRef::InterpolatedElement(node) => node.range(),
6956            AnyNodeRef::InterpolatedStringLiteralElement(node) => node.range(),
6957            AnyNodeRef::PatternMatchValue(node) => node.range(),
6958            AnyNodeRef::PatternMatchSingleton(node) => node.range(),
6959            AnyNodeRef::PatternMatchSequence(node) => node.range(),
6960            AnyNodeRef::PatternMatchMapping(node) => node.range(),
6961            AnyNodeRef::PatternMatchClass(node) => node.range(),
6962            AnyNodeRef::PatternMatchStar(node) => node.range(),
6963            AnyNodeRef::PatternMatchAs(node) => node.range(),
6964            AnyNodeRef::PatternMatchOr(node) => node.range(),
6965            AnyNodeRef::TypeParamTypeVar(node) => node.range(),
6966            AnyNodeRef::TypeParamTypeVarTuple(node) => node.range(),
6967            AnyNodeRef::TypeParamParamSpec(node) => node.range(),
6968            AnyNodeRef::InterpolatedStringFormatSpec(node) => node.range(),
6969            AnyNodeRef::PatternArguments(node) => node.range(),
6970            AnyNodeRef::PatternKeyword(node) => node.range(),
6971            AnyNodeRef::Comprehension(node) => node.range(),
6972            AnyNodeRef::Arguments(node) => node.range(),
6973            AnyNodeRef::Parameters(node) => node.range(),
6974            AnyNodeRef::Parameter(node) => node.range(),
6975            AnyNodeRef::ParameterWithDefault(node) => node.range(),
6976            AnyNodeRef::Keyword(node) => node.range(),
6977            AnyNodeRef::Alias(node) => node.range(),
6978            AnyNodeRef::WithItem(node) => node.range(),
6979            AnyNodeRef::MatchCase(node) => node.range(),
6980            AnyNodeRef::Decorator(node) => node.range(),
6981            AnyNodeRef::ElifElseClause(node) => node.range(),
6982            AnyNodeRef::TypeParams(node) => node.range(),
6983            AnyNodeRef::FString(node) => node.range(),
6984            AnyNodeRef::TString(node) => node.range(),
6985            AnyNodeRef::StringLiteral(node) => node.range(),
6986            AnyNodeRef::BytesLiteral(node) => node.range(),
6987            AnyNodeRef::Identifier(node) => node.range(),
6988        }
6989    }
6990}
6991
6992impl crate::HasNodeIndex for AnyNodeRef<'_> {
6993    fn node_index(&self) -> &crate::AtomicNodeIndex {
6994        match self {
6995            AnyNodeRef::ModModule(node) => node.node_index(),
6996            AnyNodeRef::ModExpression(node) => node.node_index(),
6997            AnyNodeRef::StmtFunctionDef(node) => node.node_index(),
6998            AnyNodeRef::StmtClassDef(node) => node.node_index(),
6999            AnyNodeRef::StmtReturn(node) => node.node_index(),
7000            AnyNodeRef::StmtDelete(node) => node.node_index(),
7001            AnyNodeRef::StmtTypeAlias(node) => node.node_index(),
7002            AnyNodeRef::StmtAssign(node) => node.node_index(),
7003            AnyNodeRef::StmtAugAssign(node) => node.node_index(),
7004            AnyNodeRef::StmtAnnAssign(node) => node.node_index(),
7005            AnyNodeRef::StmtFor(node) => node.node_index(),
7006            AnyNodeRef::StmtWhile(node) => node.node_index(),
7007            AnyNodeRef::StmtIf(node) => node.node_index(),
7008            AnyNodeRef::StmtWith(node) => node.node_index(),
7009            AnyNodeRef::StmtMatch(node) => node.node_index(),
7010            AnyNodeRef::StmtRaise(node) => node.node_index(),
7011            AnyNodeRef::StmtTry(node) => node.node_index(),
7012            AnyNodeRef::StmtAssert(node) => node.node_index(),
7013            AnyNodeRef::StmtImport(node) => node.node_index(),
7014            AnyNodeRef::StmtImportFrom(node) => node.node_index(),
7015            AnyNodeRef::StmtGlobal(node) => node.node_index(),
7016            AnyNodeRef::StmtNonlocal(node) => node.node_index(),
7017            AnyNodeRef::StmtExpr(node) => node.node_index(),
7018            AnyNodeRef::StmtPass(node) => node.node_index(),
7019            AnyNodeRef::StmtBreak(node) => node.node_index(),
7020            AnyNodeRef::StmtContinue(node) => node.node_index(),
7021            AnyNodeRef::StmtIpyEscapeCommand(node) => node.node_index(),
7022            AnyNodeRef::ExprBoolOp(node) => node.node_index(),
7023            AnyNodeRef::ExprNamed(node) => node.node_index(),
7024            AnyNodeRef::ExprBinOp(node) => node.node_index(),
7025            AnyNodeRef::ExprUnaryOp(node) => node.node_index(),
7026            AnyNodeRef::ExprLambda(node) => node.node_index(),
7027            AnyNodeRef::ExprIf(node) => node.node_index(),
7028            AnyNodeRef::ExprDict(node) => node.node_index(),
7029            AnyNodeRef::ExprSet(node) => node.node_index(),
7030            AnyNodeRef::ExprListComp(node) => node.node_index(),
7031            AnyNodeRef::ExprSetComp(node) => node.node_index(),
7032            AnyNodeRef::ExprDictComp(node) => node.node_index(),
7033            AnyNodeRef::ExprGenerator(node) => node.node_index(),
7034            AnyNodeRef::ExprAwait(node) => node.node_index(),
7035            AnyNodeRef::ExprYield(node) => node.node_index(),
7036            AnyNodeRef::ExprYieldFrom(node) => node.node_index(),
7037            AnyNodeRef::ExprCompare(node) => node.node_index(),
7038            AnyNodeRef::ExprCall(node) => node.node_index(),
7039            AnyNodeRef::ExprFString(node) => node.node_index(),
7040            AnyNodeRef::ExprTString(node) => node.node_index(),
7041            AnyNodeRef::ExprStringLiteral(node) => node.node_index(),
7042            AnyNodeRef::ExprBytesLiteral(node) => node.node_index(),
7043            AnyNodeRef::ExprNumberLiteral(node) => node.node_index(),
7044            AnyNodeRef::ExprBooleanLiteral(node) => node.node_index(),
7045            AnyNodeRef::ExprNoneLiteral(node) => node.node_index(),
7046            AnyNodeRef::ExprEllipsisLiteral(node) => node.node_index(),
7047            AnyNodeRef::ExprAttribute(node) => node.node_index(),
7048            AnyNodeRef::ExprSubscript(node) => node.node_index(),
7049            AnyNodeRef::ExprStarred(node) => node.node_index(),
7050            AnyNodeRef::ExprName(node) => node.node_index(),
7051            AnyNodeRef::ExprList(node) => node.node_index(),
7052            AnyNodeRef::ExprTuple(node) => node.node_index(),
7053            AnyNodeRef::ExprSlice(node) => node.node_index(),
7054            AnyNodeRef::ExprIpyEscapeCommand(node) => node.node_index(),
7055            AnyNodeRef::ExceptHandlerExceptHandler(node) => node.node_index(),
7056            AnyNodeRef::InterpolatedElement(node) => node.node_index(),
7057            AnyNodeRef::InterpolatedStringLiteralElement(node) => node.node_index(),
7058            AnyNodeRef::PatternMatchValue(node) => node.node_index(),
7059            AnyNodeRef::PatternMatchSingleton(node) => node.node_index(),
7060            AnyNodeRef::PatternMatchSequence(node) => node.node_index(),
7061            AnyNodeRef::PatternMatchMapping(node) => node.node_index(),
7062            AnyNodeRef::PatternMatchClass(node) => node.node_index(),
7063            AnyNodeRef::PatternMatchStar(node) => node.node_index(),
7064            AnyNodeRef::PatternMatchAs(node) => node.node_index(),
7065            AnyNodeRef::PatternMatchOr(node) => node.node_index(),
7066            AnyNodeRef::TypeParamTypeVar(node) => node.node_index(),
7067            AnyNodeRef::TypeParamTypeVarTuple(node) => node.node_index(),
7068            AnyNodeRef::TypeParamParamSpec(node) => node.node_index(),
7069            AnyNodeRef::InterpolatedStringFormatSpec(node) => node.node_index(),
7070            AnyNodeRef::PatternArguments(node) => node.node_index(),
7071            AnyNodeRef::PatternKeyword(node) => node.node_index(),
7072            AnyNodeRef::Comprehension(node) => node.node_index(),
7073            AnyNodeRef::Arguments(node) => node.node_index(),
7074            AnyNodeRef::Parameters(node) => node.node_index(),
7075            AnyNodeRef::Parameter(node) => node.node_index(),
7076            AnyNodeRef::ParameterWithDefault(node) => node.node_index(),
7077            AnyNodeRef::Keyword(node) => node.node_index(),
7078            AnyNodeRef::Alias(node) => node.node_index(),
7079            AnyNodeRef::WithItem(node) => node.node_index(),
7080            AnyNodeRef::MatchCase(node) => node.node_index(),
7081            AnyNodeRef::Decorator(node) => node.node_index(),
7082            AnyNodeRef::ElifElseClause(node) => node.node_index(),
7083            AnyNodeRef::TypeParams(node) => node.node_index(),
7084            AnyNodeRef::FString(node) => node.node_index(),
7085            AnyNodeRef::TString(node) => node.node_index(),
7086            AnyNodeRef::StringLiteral(node) => node.node_index(),
7087            AnyNodeRef::BytesLiteral(node) => node.node_index(),
7088            AnyNodeRef::Identifier(node) => node.node_index(),
7089        }
7090    }
7091}
7092
7093impl AnyNodeRef<'_> {
7094    pub fn as_ptr(&self) -> std::ptr::NonNull<()> {
7095        match self {
7096            AnyNodeRef::ModModule(node) => std::ptr::NonNull::from(*node).cast(),
7097            AnyNodeRef::ModExpression(node) => std::ptr::NonNull::from(*node).cast(),
7098            AnyNodeRef::StmtFunctionDef(node) => std::ptr::NonNull::from(*node).cast(),
7099            AnyNodeRef::StmtClassDef(node) => std::ptr::NonNull::from(*node).cast(),
7100            AnyNodeRef::StmtReturn(node) => std::ptr::NonNull::from(*node).cast(),
7101            AnyNodeRef::StmtDelete(node) => std::ptr::NonNull::from(*node).cast(),
7102            AnyNodeRef::StmtTypeAlias(node) => std::ptr::NonNull::from(*node).cast(),
7103            AnyNodeRef::StmtAssign(node) => std::ptr::NonNull::from(*node).cast(),
7104            AnyNodeRef::StmtAugAssign(node) => std::ptr::NonNull::from(*node).cast(),
7105            AnyNodeRef::StmtAnnAssign(node) => std::ptr::NonNull::from(*node).cast(),
7106            AnyNodeRef::StmtFor(node) => std::ptr::NonNull::from(*node).cast(),
7107            AnyNodeRef::StmtWhile(node) => std::ptr::NonNull::from(*node).cast(),
7108            AnyNodeRef::StmtIf(node) => std::ptr::NonNull::from(*node).cast(),
7109            AnyNodeRef::StmtWith(node) => std::ptr::NonNull::from(*node).cast(),
7110            AnyNodeRef::StmtMatch(node) => std::ptr::NonNull::from(*node).cast(),
7111            AnyNodeRef::StmtRaise(node) => std::ptr::NonNull::from(*node).cast(),
7112            AnyNodeRef::StmtTry(node) => std::ptr::NonNull::from(*node).cast(),
7113            AnyNodeRef::StmtAssert(node) => std::ptr::NonNull::from(*node).cast(),
7114            AnyNodeRef::StmtImport(node) => std::ptr::NonNull::from(*node).cast(),
7115            AnyNodeRef::StmtImportFrom(node) => std::ptr::NonNull::from(*node).cast(),
7116            AnyNodeRef::StmtGlobal(node) => std::ptr::NonNull::from(*node).cast(),
7117            AnyNodeRef::StmtNonlocal(node) => std::ptr::NonNull::from(*node).cast(),
7118            AnyNodeRef::StmtExpr(node) => std::ptr::NonNull::from(*node).cast(),
7119            AnyNodeRef::StmtPass(node) => std::ptr::NonNull::from(*node).cast(),
7120            AnyNodeRef::StmtBreak(node) => std::ptr::NonNull::from(*node).cast(),
7121            AnyNodeRef::StmtContinue(node) => std::ptr::NonNull::from(*node).cast(),
7122            AnyNodeRef::StmtIpyEscapeCommand(node) => std::ptr::NonNull::from(*node).cast(),
7123            AnyNodeRef::ExprBoolOp(node) => std::ptr::NonNull::from(*node).cast(),
7124            AnyNodeRef::ExprNamed(node) => std::ptr::NonNull::from(*node).cast(),
7125            AnyNodeRef::ExprBinOp(node) => std::ptr::NonNull::from(*node).cast(),
7126            AnyNodeRef::ExprUnaryOp(node) => std::ptr::NonNull::from(*node).cast(),
7127            AnyNodeRef::ExprLambda(node) => std::ptr::NonNull::from(*node).cast(),
7128            AnyNodeRef::ExprIf(node) => std::ptr::NonNull::from(*node).cast(),
7129            AnyNodeRef::ExprDict(node) => std::ptr::NonNull::from(*node).cast(),
7130            AnyNodeRef::ExprSet(node) => std::ptr::NonNull::from(*node).cast(),
7131            AnyNodeRef::ExprListComp(node) => std::ptr::NonNull::from(*node).cast(),
7132            AnyNodeRef::ExprSetComp(node) => std::ptr::NonNull::from(*node).cast(),
7133            AnyNodeRef::ExprDictComp(node) => std::ptr::NonNull::from(*node).cast(),
7134            AnyNodeRef::ExprGenerator(node) => std::ptr::NonNull::from(*node).cast(),
7135            AnyNodeRef::ExprAwait(node) => std::ptr::NonNull::from(*node).cast(),
7136            AnyNodeRef::ExprYield(node) => std::ptr::NonNull::from(*node).cast(),
7137            AnyNodeRef::ExprYieldFrom(node) => std::ptr::NonNull::from(*node).cast(),
7138            AnyNodeRef::ExprCompare(node) => std::ptr::NonNull::from(*node).cast(),
7139            AnyNodeRef::ExprCall(node) => std::ptr::NonNull::from(*node).cast(),
7140            AnyNodeRef::ExprFString(node) => std::ptr::NonNull::from(*node).cast(),
7141            AnyNodeRef::ExprTString(node) => std::ptr::NonNull::from(*node).cast(),
7142            AnyNodeRef::ExprStringLiteral(node) => std::ptr::NonNull::from(*node).cast(),
7143            AnyNodeRef::ExprBytesLiteral(node) => std::ptr::NonNull::from(*node).cast(),
7144            AnyNodeRef::ExprNumberLiteral(node) => std::ptr::NonNull::from(*node).cast(),
7145            AnyNodeRef::ExprBooleanLiteral(node) => std::ptr::NonNull::from(*node).cast(),
7146            AnyNodeRef::ExprNoneLiteral(node) => std::ptr::NonNull::from(*node).cast(),
7147            AnyNodeRef::ExprEllipsisLiteral(node) => std::ptr::NonNull::from(*node).cast(),
7148            AnyNodeRef::ExprAttribute(node) => std::ptr::NonNull::from(*node).cast(),
7149            AnyNodeRef::ExprSubscript(node) => std::ptr::NonNull::from(*node).cast(),
7150            AnyNodeRef::ExprStarred(node) => std::ptr::NonNull::from(*node).cast(),
7151            AnyNodeRef::ExprName(node) => std::ptr::NonNull::from(*node).cast(),
7152            AnyNodeRef::ExprList(node) => std::ptr::NonNull::from(*node).cast(),
7153            AnyNodeRef::ExprTuple(node) => std::ptr::NonNull::from(*node).cast(),
7154            AnyNodeRef::ExprSlice(node) => std::ptr::NonNull::from(*node).cast(),
7155            AnyNodeRef::ExprIpyEscapeCommand(node) => std::ptr::NonNull::from(*node).cast(),
7156            AnyNodeRef::ExceptHandlerExceptHandler(node) => std::ptr::NonNull::from(*node).cast(),
7157            AnyNodeRef::InterpolatedElement(node) => std::ptr::NonNull::from(*node).cast(),
7158            AnyNodeRef::InterpolatedStringLiteralElement(node) => {
7159                std::ptr::NonNull::from(*node).cast()
7160            }
7161            AnyNodeRef::PatternMatchValue(node) => std::ptr::NonNull::from(*node).cast(),
7162            AnyNodeRef::PatternMatchSingleton(node) => std::ptr::NonNull::from(*node).cast(),
7163            AnyNodeRef::PatternMatchSequence(node) => std::ptr::NonNull::from(*node).cast(),
7164            AnyNodeRef::PatternMatchMapping(node) => std::ptr::NonNull::from(*node).cast(),
7165            AnyNodeRef::PatternMatchClass(node) => std::ptr::NonNull::from(*node).cast(),
7166            AnyNodeRef::PatternMatchStar(node) => std::ptr::NonNull::from(*node).cast(),
7167            AnyNodeRef::PatternMatchAs(node) => std::ptr::NonNull::from(*node).cast(),
7168            AnyNodeRef::PatternMatchOr(node) => std::ptr::NonNull::from(*node).cast(),
7169            AnyNodeRef::TypeParamTypeVar(node) => std::ptr::NonNull::from(*node).cast(),
7170            AnyNodeRef::TypeParamTypeVarTuple(node) => std::ptr::NonNull::from(*node).cast(),
7171            AnyNodeRef::TypeParamParamSpec(node) => std::ptr::NonNull::from(*node).cast(),
7172            AnyNodeRef::InterpolatedStringFormatSpec(node) => std::ptr::NonNull::from(*node).cast(),
7173            AnyNodeRef::PatternArguments(node) => std::ptr::NonNull::from(*node).cast(),
7174            AnyNodeRef::PatternKeyword(node) => std::ptr::NonNull::from(*node).cast(),
7175            AnyNodeRef::Comprehension(node) => std::ptr::NonNull::from(*node).cast(),
7176            AnyNodeRef::Arguments(node) => std::ptr::NonNull::from(*node).cast(),
7177            AnyNodeRef::Parameters(node) => std::ptr::NonNull::from(*node).cast(),
7178            AnyNodeRef::Parameter(node) => std::ptr::NonNull::from(*node).cast(),
7179            AnyNodeRef::ParameterWithDefault(node) => std::ptr::NonNull::from(*node).cast(),
7180            AnyNodeRef::Keyword(node) => std::ptr::NonNull::from(*node).cast(),
7181            AnyNodeRef::Alias(node) => std::ptr::NonNull::from(*node).cast(),
7182            AnyNodeRef::WithItem(node) => std::ptr::NonNull::from(*node).cast(),
7183            AnyNodeRef::MatchCase(node) => std::ptr::NonNull::from(*node).cast(),
7184            AnyNodeRef::Decorator(node) => std::ptr::NonNull::from(*node).cast(),
7185            AnyNodeRef::ElifElseClause(node) => std::ptr::NonNull::from(*node).cast(),
7186            AnyNodeRef::TypeParams(node) => std::ptr::NonNull::from(*node).cast(),
7187            AnyNodeRef::FString(node) => std::ptr::NonNull::from(*node).cast(),
7188            AnyNodeRef::TString(node) => std::ptr::NonNull::from(*node).cast(),
7189            AnyNodeRef::StringLiteral(node) => std::ptr::NonNull::from(*node).cast(),
7190            AnyNodeRef::BytesLiteral(node) => std::ptr::NonNull::from(*node).cast(),
7191            AnyNodeRef::Identifier(node) => std::ptr::NonNull::from(*node).cast(),
7192        }
7193    }
7194}
7195
7196impl<'a> AnyNodeRef<'a> {
7197    pub fn visit_source_order<'b, V>(self, visitor: &mut V)
7198    where
7199        V: crate::visitor::source_order::SourceOrderVisitor<'b> + ?Sized,
7200        'a: 'b,
7201    {
7202        match self {
7203            AnyNodeRef::ModModule(node) => node.visit_source_order(visitor),
7204            AnyNodeRef::ModExpression(node) => node.visit_source_order(visitor),
7205            AnyNodeRef::StmtFunctionDef(node) => node.visit_source_order(visitor),
7206            AnyNodeRef::StmtClassDef(node) => node.visit_source_order(visitor),
7207            AnyNodeRef::StmtReturn(node) => node.visit_source_order(visitor),
7208            AnyNodeRef::StmtDelete(node) => node.visit_source_order(visitor),
7209            AnyNodeRef::StmtTypeAlias(node) => node.visit_source_order(visitor),
7210            AnyNodeRef::StmtAssign(node) => node.visit_source_order(visitor),
7211            AnyNodeRef::StmtAugAssign(node) => node.visit_source_order(visitor),
7212            AnyNodeRef::StmtAnnAssign(node) => node.visit_source_order(visitor),
7213            AnyNodeRef::StmtFor(node) => node.visit_source_order(visitor),
7214            AnyNodeRef::StmtWhile(node) => node.visit_source_order(visitor),
7215            AnyNodeRef::StmtIf(node) => node.visit_source_order(visitor),
7216            AnyNodeRef::StmtWith(node) => node.visit_source_order(visitor),
7217            AnyNodeRef::StmtMatch(node) => node.visit_source_order(visitor),
7218            AnyNodeRef::StmtRaise(node) => node.visit_source_order(visitor),
7219            AnyNodeRef::StmtTry(node) => node.visit_source_order(visitor),
7220            AnyNodeRef::StmtAssert(node) => node.visit_source_order(visitor),
7221            AnyNodeRef::StmtImport(node) => node.visit_source_order(visitor),
7222            AnyNodeRef::StmtImportFrom(node) => node.visit_source_order(visitor),
7223            AnyNodeRef::StmtGlobal(node) => node.visit_source_order(visitor),
7224            AnyNodeRef::StmtNonlocal(node) => node.visit_source_order(visitor),
7225            AnyNodeRef::StmtExpr(node) => node.visit_source_order(visitor),
7226            AnyNodeRef::StmtPass(node) => node.visit_source_order(visitor),
7227            AnyNodeRef::StmtBreak(node) => node.visit_source_order(visitor),
7228            AnyNodeRef::StmtContinue(node) => node.visit_source_order(visitor),
7229            AnyNodeRef::StmtIpyEscapeCommand(node) => node.visit_source_order(visitor),
7230            AnyNodeRef::ExprBoolOp(node) => node.visit_source_order(visitor),
7231            AnyNodeRef::ExprNamed(node) => node.visit_source_order(visitor),
7232            AnyNodeRef::ExprBinOp(node) => node.visit_source_order(visitor),
7233            AnyNodeRef::ExprUnaryOp(node) => node.visit_source_order(visitor),
7234            AnyNodeRef::ExprLambda(node) => node.visit_source_order(visitor),
7235            AnyNodeRef::ExprIf(node) => node.visit_source_order(visitor),
7236            AnyNodeRef::ExprDict(node) => node.visit_source_order(visitor),
7237            AnyNodeRef::ExprSet(node) => node.visit_source_order(visitor),
7238            AnyNodeRef::ExprListComp(node) => node.visit_source_order(visitor),
7239            AnyNodeRef::ExprSetComp(node) => node.visit_source_order(visitor),
7240            AnyNodeRef::ExprDictComp(node) => node.visit_source_order(visitor),
7241            AnyNodeRef::ExprGenerator(node) => node.visit_source_order(visitor),
7242            AnyNodeRef::ExprAwait(node) => node.visit_source_order(visitor),
7243            AnyNodeRef::ExprYield(node) => node.visit_source_order(visitor),
7244            AnyNodeRef::ExprYieldFrom(node) => node.visit_source_order(visitor),
7245            AnyNodeRef::ExprCompare(node) => node.visit_source_order(visitor),
7246            AnyNodeRef::ExprCall(node) => node.visit_source_order(visitor),
7247            AnyNodeRef::ExprFString(node) => node.visit_source_order(visitor),
7248            AnyNodeRef::ExprTString(node) => node.visit_source_order(visitor),
7249            AnyNodeRef::ExprStringLiteral(node) => node.visit_source_order(visitor),
7250            AnyNodeRef::ExprBytesLiteral(node) => node.visit_source_order(visitor),
7251            AnyNodeRef::ExprNumberLiteral(node) => node.visit_source_order(visitor),
7252            AnyNodeRef::ExprBooleanLiteral(node) => node.visit_source_order(visitor),
7253            AnyNodeRef::ExprNoneLiteral(node) => node.visit_source_order(visitor),
7254            AnyNodeRef::ExprEllipsisLiteral(node) => node.visit_source_order(visitor),
7255            AnyNodeRef::ExprAttribute(node) => node.visit_source_order(visitor),
7256            AnyNodeRef::ExprSubscript(node) => node.visit_source_order(visitor),
7257            AnyNodeRef::ExprStarred(node) => node.visit_source_order(visitor),
7258            AnyNodeRef::ExprName(node) => node.visit_source_order(visitor),
7259            AnyNodeRef::ExprList(node) => node.visit_source_order(visitor),
7260            AnyNodeRef::ExprTuple(node) => node.visit_source_order(visitor),
7261            AnyNodeRef::ExprSlice(node) => node.visit_source_order(visitor),
7262            AnyNodeRef::ExprIpyEscapeCommand(node) => node.visit_source_order(visitor),
7263            AnyNodeRef::ExceptHandlerExceptHandler(node) => node.visit_source_order(visitor),
7264            AnyNodeRef::InterpolatedElement(node) => node.visit_source_order(visitor),
7265            AnyNodeRef::InterpolatedStringLiteralElement(node) => node.visit_source_order(visitor),
7266            AnyNodeRef::PatternMatchValue(node) => node.visit_source_order(visitor),
7267            AnyNodeRef::PatternMatchSingleton(node) => node.visit_source_order(visitor),
7268            AnyNodeRef::PatternMatchSequence(node) => node.visit_source_order(visitor),
7269            AnyNodeRef::PatternMatchMapping(node) => node.visit_source_order(visitor),
7270            AnyNodeRef::PatternMatchClass(node) => node.visit_source_order(visitor),
7271            AnyNodeRef::PatternMatchStar(node) => node.visit_source_order(visitor),
7272            AnyNodeRef::PatternMatchAs(node) => node.visit_source_order(visitor),
7273            AnyNodeRef::PatternMatchOr(node) => node.visit_source_order(visitor),
7274            AnyNodeRef::TypeParamTypeVar(node) => node.visit_source_order(visitor),
7275            AnyNodeRef::TypeParamTypeVarTuple(node) => node.visit_source_order(visitor),
7276            AnyNodeRef::TypeParamParamSpec(node) => node.visit_source_order(visitor),
7277            AnyNodeRef::InterpolatedStringFormatSpec(node) => node.visit_source_order(visitor),
7278            AnyNodeRef::PatternArguments(node) => node.visit_source_order(visitor),
7279            AnyNodeRef::PatternKeyword(node) => node.visit_source_order(visitor),
7280            AnyNodeRef::Comprehension(node) => node.visit_source_order(visitor),
7281            AnyNodeRef::Arguments(node) => node.visit_source_order(visitor),
7282            AnyNodeRef::Parameters(node) => node.visit_source_order(visitor),
7283            AnyNodeRef::Parameter(node) => node.visit_source_order(visitor),
7284            AnyNodeRef::ParameterWithDefault(node) => node.visit_source_order(visitor),
7285            AnyNodeRef::Keyword(node) => node.visit_source_order(visitor),
7286            AnyNodeRef::Alias(node) => node.visit_source_order(visitor),
7287            AnyNodeRef::WithItem(node) => node.visit_source_order(visitor),
7288            AnyNodeRef::MatchCase(node) => node.visit_source_order(visitor),
7289            AnyNodeRef::Decorator(node) => node.visit_source_order(visitor),
7290            AnyNodeRef::ElifElseClause(node) => node.visit_source_order(visitor),
7291            AnyNodeRef::TypeParams(node) => node.visit_source_order(visitor),
7292            AnyNodeRef::FString(node) => node.visit_source_order(visitor),
7293            AnyNodeRef::TString(node) => node.visit_source_order(visitor),
7294            AnyNodeRef::StringLiteral(node) => node.visit_source_order(visitor),
7295            AnyNodeRef::BytesLiteral(node) => node.visit_source_order(visitor),
7296            AnyNodeRef::Identifier(node) => node.visit_source_order(visitor),
7297        }
7298    }
7299}
7300
7301impl AnyNodeRef<'_> {
7302    pub const fn is_module(self) -> bool {
7303        matches!(
7304            self,
7305            AnyNodeRef::ModModule(_) | AnyNodeRef::ModExpression(_)
7306        )
7307    }
7308}
7309
7310impl AnyNodeRef<'_> {
7311    pub const fn is_statement(self) -> bool {
7312        matches!(
7313            self,
7314            AnyNodeRef::StmtFunctionDef(_)
7315                | AnyNodeRef::StmtClassDef(_)
7316                | AnyNodeRef::StmtReturn(_)
7317                | AnyNodeRef::StmtDelete(_)
7318                | AnyNodeRef::StmtTypeAlias(_)
7319                | AnyNodeRef::StmtAssign(_)
7320                | AnyNodeRef::StmtAugAssign(_)
7321                | AnyNodeRef::StmtAnnAssign(_)
7322                | AnyNodeRef::StmtFor(_)
7323                | AnyNodeRef::StmtWhile(_)
7324                | AnyNodeRef::StmtIf(_)
7325                | AnyNodeRef::StmtWith(_)
7326                | AnyNodeRef::StmtMatch(_)
7327                | AnyNodeRef::StmtRaise(_)
7328                | AnyNodeRef::StmtTry(_)
7329                | AnyNodeRef::StmtAssert(_)
7330                | AnyNodeRef::StmtImport(_)
7331                | AnyNodeRef::StmtImportFrom(_)
7332                | AnyNodeRef::StmtGlobal(_)
7333                | AnyNodeRef::StmtNonlocal(_)
7334                | AnyNodeRef::StmtExpr(_)
7335                | AnyNodeRef::StmtPass(_)
7336                | AnyNodeRef::StmtBreak(_)
7337                | AnyNodeRef::StmtContinue(_)
7338                | AnyNodeRef::StmtIpyEscapeCommand(_)
7339        )
7340    }
7341}
7342
7343impl AnyNodeRef<'_> {
7344    pub const fn is_expression(self) -> bool {
7345        matches!(
7346            self,
7347            AnyNodeRef::ExprBoolOp(_)
7348                | AnyNodeRef::ExprNamed(_)
7349                | AnyNodeRef::ExprBinOp(_)
7350                | AnyNodeRef::ExprUnaryOp(_)
7351                | AnyNodeRef::ExprLambda(_)
7352                | AnyNodeRef::ExprIf(_)
7353                | AnyNodeRef::ExprDict(_)
7354                | AnyNodeRef::ExprSet(_)
7355                | AnyNodeRef::ExprListComp(_)
7356                | AnyNodeRef::ExprSetComp(_)
7357                | AnyNodeRef::ExprDictComp(_)
7358                | AnyNodeRef::ExprGenerator(_)
7359                | AnyNodeRef::ExprAwait(_)
7360                | AnyNodeRef::ExprYield(_)
7361                | AnyNodeRef::ExprYieldFrom(_)
7362                | AnyNodeRef::ExprCompare(_)
7363                | AnyNodeRef::ExprCall(_)
7364                | AnyNodeRef::ExprFString(_)
7365                | AnyNodeRef::ExprTString(_)
7366                | AnyNodeRef::ExprStringLiteral(_)
7367                | AnyNodeRef::ExprBytesLiteral(_)
7368                | AnyNodeRef::ExprNumberLiteral(_)
7369                | AnyNodeRef::ExprBooleanLiteral(_)
7370                | AnyNodeRef::ExprNoneLiteral(_)
7371                | AnyNodeRef::ExprEllipsisLiteral(_)
7372                | AnyNodeRef::ExprAttribute(_)
7373                | AnyNodeRef::ExprSubscript(_)
7374                | AnyNodeRef::ExprStarred(_)
7375                | AnyNodeRef::ExprName(_)
7376                | AnyNodeRef::ExprList(_)
7377                | AnyNodeRef::ExprTuple(_)
7378                | AnyNodeRef::ExprSlice(_)
7379                | AnyNodeRef::ExprIpyEscapeCommand(_)
7380        )
7381    }
7382}
7383
7384impl AnyNodeRef<'_> {
7385    pub const fn is_except_handler(self) -> bool {
7386        matches!(self, AnyNodeRef::ExceptHandlerExceptHandler(_))
7387    }
7388}
7389
7390impl AnyNodeRef<'_> {
7391    pub const fn is_interpolated_string_element(self) -> bool {
7392        matches!(
7393            self,
7394            AnyNodeRef::InterpolatedElement(_) | AnyNodeRef::InterpolatedStringLiteralElement(_)
7395        )
7396    }
7397}
7398
7399impl AnyNodeRef<'_> {
7400    pub const fn is_pattern(self) -> bool {
7401        matches!(
7402            self,
7403            AnyNodeRef::PatternMatchValue(_)
7404                | AnyNodeRef::PatternMatchSingleton(_)
7405                | AnyNodeRef::PatternMatchSequence(_)
7406                | AnyNodeRef::PatternMatchMapping(_)
7407                | AnyNodeRef::PatternMatchClass(_)
7408                | AnyNodeRef::PatternMatchStar(_)
7409                | AnyNodeRef::PatternMatchAs(_)
7410                | AnyNodeRef::PatternMatchOr(_)
7411        )
7412    }
7413}
7414
7415impl AnyNodeRef<'_> {
7416    pub const fn is_type_param(self) -> bool {
7417        matches!(
7418            self,
7419            AnyNodeRef::TypeParamTypeVar(_)
7420                | AnyNodeRef::TypeParamTypeVarTuple(_)
7421                | AnyNodeRef::TypeParamParamSpec(_)
7422        )
7423    }
7424}
7425
7426/// An enumeration of all AST nodes.
7427///
7428/// Unlike `AnyNodeRef`, this type does not flatten nested enums, so its variants only
7429/// consist of the "root" AST node types. This is useful as it exposes references to the
7430/// original enums, not just references to their inner values.
7431///
7432/// For example, `AnyRootNodeRef::Mod` contains a reference to the `Mod` enum, while
7433/// `AnyNodeRef` has top-level `AnyNodeRef::ModModule` and `AnyNodeRef::ModExpression`
7434/// variants.
7435#[derive(Copy, Clone, Debug, PartialEq)]
7436#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
7437pub enum AnyRootNodeRef<'a> {
7438    Mod(&'a Mod),
7439    Stmt(&'a Stmt),
7440    Expr(&'a Expr),
7441    ExceptHandler(&'a ExceptHandler),
7442    InterpolatedStringElement(&'a InterpolatedStringElement),
7443    Pattern(&'a Pattern),
7444    TypeParam(&'a TypeParam),
7445    InterpolatedStringFormatSpec(&'a crate::InterpolatedStringFormatSpec),
7446    PatternArguments(&'a crate::PatternArguments),
7447    PatternKeyword(&'a crate::PatternKeyword),
7448    Comprehension(&'a crate::Comprehension),
7449    Arguments(&'a crate::Arguments),
7450    Parameters(&'a crate::Parameters),
7451    Parameter(&'a crate::Parameter),
7452    ParameterWithDefault(&'a crate::ParameterWithDefault),
7453    Keyword(&'a crate::Keyword),
7454    Alias(&'a crate::Alias),
7455    WithItem(&'a crate::WithItem),
7456    MatchCase(&'a crate::MatchCase),
7457    Decorator(&'a crate::Decorator),
7458    ElifElseClause(&'a crate::ElifElseClause),
7459    TypeParams(&'a crate::TypeParams),
7460    FString(&'a crate::FString),
7461    TString(&'a crate::TString),
7462    StringLiteral(&'a crate::StringLiteral),
7463    BytesLiteral(&'a crate::BytesLiteral),
7464    Identifier(&'a crate::Identifier),
7465}
7466
7467impl<'a> From<&'a Mod> for AnyRootNodeRef<'a> {
7468    fn from(node: &'a Mod) -> AnyRootNodeRef<'a> {
7469        AnyRootNodeRef::Mod(node)
7470    }
7471}
7472
7473impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a Mod {
7474    type Error = ();
7475    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a Mod, ()> {
7476        match node {
7477            AnyRootNodeRef::Mod(node) => Ok(node),
7478            _ => Err(()),
7479        }
7480    }
7481}
7482
7483impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ModModule {
7484    type Error = ();
7485    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ModModule, ()> {
7486        match node {
7487            AnyRootNodeRef::Mod(Mod::Module(node)) => Ok(node),
7488            _ => Err(()),
7489        }
7490    }
7491}
7492
7493impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ModExpression {
7494    type Error = ();
7495    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ModExpression, ()> {
7496        match node {
7497            AnyRootNodeRef::Mod(Mod::Expression(node)) => Ok(node),
7498            _ => Err(()),
7499        }
7500    }
7501}
7502
7503impl<'a> From<&'a Stmt> for AnyRootNodeRef<'a> {
7504    fn from(node: &'a Stmt) -> AnyRootNodeRef<'a> {
7505        AnyRootNodeRef::Stmt(node)
7506    }
7507}
7508
7509impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a Stmt {
7510    type Error = ();
7511    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a Stmt, ()> {
7512        match node {
7513            AnyRootNodeRef::Stmt(node) => Ok(node),
7514            _ => Err(()),
7515        }
7516    }
7517}
7518
7519impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtFunctionDef {
7520    type Error = ();
7521    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtFunctionDef, ()> {
7522        match node {
7523            AnyRootNodeRef::Stmt(Stmt::FunctionDef(node)) => Ok(node),
7524            _ => Err(()),
7525        }
7526    }
7527}
7528
7529impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtClassDef {
7530    type Error = ();
7531    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtClassDef, ()> {
7532        match node {
7533            AnyRootNodeRef::Stmt(Stmt::ClassDef(node)) => Ok(node),
7534            _ => Err(()),
7535        }
7536    }
7537}
7538
7539impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtReturn {
7540    type Error = ();
7541    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtReturn, ()> {
7542        match node {
7543            AnyRootNodeRef::Stmt(Stmt::Return(node)) => Ok(node),
7544            _ => Err(()),
7545        }
7546    }
7547}
7548
7549impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtDelete {
7550    type Error = ();
7551    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtDelete, ()> {
7552        match node {
7553            AnyRootNodeRef::Stmt(Stmt::Delete(node)) => Ok(node),
7554            _ => Err(()),
7555        }
7556    }
7557}
7558
7559impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtTypeAlias {
7560    type Error = ();
7561    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtTypeAlias, ()> {
7562        match node {
7563            AnyRootNodeRef::Stmt(Stmt::TypeAlias(node)) => Ok(node),
7564            _ => Err(()),
7565        }
7566    }
7567}
7568
7569impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtAssign {
7570    type Error = ();
7571    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtAssign, ()> {
7572        match node {
7573            AnyRootNodeRef::Stmt(Stmt::Assign(node)) => Ok(node),
7574            _ => Err(()),
7575        }
7576    }
7577}
7578
7579impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtAugAssign {
7580    type Error = ();
7581    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtAugAssign, ()> {
7582        match node {
7583            AnyRootNodeRef::Stmt(Stmt::AugAssign(node)) => Ok(node),
7584            _ => Err(()),
7585        }
7586    }
7587}
7588
7589impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtAnnAssign {
7590    type Error = ();
7591    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtAnnAssign, ()> {
7592        match node {
7593            AnyRootNodeRef::Stmt(Stmt::AnnAssign(node)) => Ok(node),
7594            _ => Err(()),
7595        }
7596    }
7597}
7598
7599impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtFor {
7600    type Error = ();
7601    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtFor, ()> {
7602        match node {
7603            AnyRootNodeRef::Stmt(Stmt::For(node)) => Ok(node),
7604            _ => Err(()),
7605        }
7606    }
7607}
7608
7609impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtWhile {
7610    type Error = ();
7611    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtWhile, ()> {
7612        match node {
7613            AnyRootNodeRef::Stmt(Stmt::While(node)) => Ok(node),
7614            _ => Err(()),
7615        }
7616    }
7617}
7618
7619impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtIf {
7620    type Error = ();
7621    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtIf, ()> {
7622        match node {
7623            AnyRootNodeRef::Stmt(Stmt::If(node)) => Ok(node),
7624            _ => Err(()),
7625        }
7626    }
7627}
7628
7629impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtWith {
7630    type Error = ();
7631    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtWith, ()> {
7632        match node {
7633            AnyRootNodeRef::Stmt(Stmt::With(node)) => Ok(node),
7634            _ => Err(()),
7635        }
7636    }
7637}
7638
7639impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtMatch {
7640    type Error = ();
7641    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtMatch, ()> {
7642        match node {
7643            AnyRootNodeRef::Stmt(Stmt::Match(node)) => Ok(node),
7644            _ => Err(()),
7645        }
7646    }
7647}
7648
7649impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtRaise {
7650    type Error = ();
7651    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtRaise, ()> {
7652        match node {
7653            AnyRootNodeRef::Stmt(Stmt::Raise(node)) => Ok(node),
7654            _ => Err(()),
7655        }
7656    }
7657}
7658
7659impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtTry {
7660    type Error = ();
7661    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtTry, ()> {
7662        match node {
7663            AnyRootNodeRef::Stmt(Stmt::Try(node)) => Ok(node),
7664            _ => Err(()),
7665        }
7666    }
7667}
7668
7669impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtAssert {
7670    type Error = ();
7671    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtAssert, ()> {
7672        match node {
7673            AnyRootNodeRef::Stmt(Stmt::Assert(node)) => Ok(node),
7674            _ => Err(()),
7675        }
7676    }
7677}
7678
7679impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtImport {
7680    type Error = ();
7681    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtImport, ()> {
7682        match node {
7683            AnyRootNodeRef::Stmt(Stmt::Import(node)) => Ok(node),
7684            _ => Err(()),
7685        }
7686    }
7687}
7688
7689impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtImportFrom {
7690    type Error = ();
7691    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtImportFrom, ()> {
7692        match node {
7693            AnyRootNodeRef::Stmt(Stmt::ImportFrom(node)) => Ok(node),
7694            _ => Err(()),
7695        }
7696    }
7697}
7698
7699impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtGlobal {
7700    type Error = ();
7701    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtGlobal, ()> {
7702        match node {
7703            AnyRootNodeRef::Stmt(Stmt::Global(node)) => Ok(node),
7704            _ => Err(()),
7705        }
7706    }
7707}
7708
7709impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtNonlocal {
7710    type Error = ();
7711    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtNonlocal, ()> {
7712        match node {
7713            AnyRootNodeRef::Stmt(Stmt::Nonlocal(node)) => Ok(node),
7714            _ => Err(()),
7715        }
7716    }
7717}
7718
7719impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtExpr {
7720    type Error = ();
7721    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtExpr, ()> {
7722        match node {
7723            AnyRootNodeRef::Stmt(Stmt::Expr(node)) => Ok(node),
7724            _ => Err(()),
7725        }
7726    }
7727}
7728
7729impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtPass {
7730    type Error = ();
7731    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtPass, ()> {
7732        match node {
7733            AnyRootNodeRef::Stmt(Stmt::Pass(node)) => Ok(node),
7734            _ => Err(()),
7735        }
7736    }
7737}
7738
7739impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtBreak {
7740    type Error = ();
7741    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtBreak, ()> {
7742        match node {
7743            AnyRootNodeRef::Stmt(Stmt::Break(node)) => Ok(node),
7744            _ => Err(()),
7745        }
7746    }
7747}
7748
7749impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtContinue {
7750    type Error = ();
7751    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtContinue, ()> {
7752        match node {
7753            AnyRootNodeRef::Stmt(Stmt::Continue(node)) => Ok(node),
7754            _ => Err(()),
7755        }
7756    }
7757}
7758
7759impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StmtIpyEscapeCommand {
7760    type Error = ();
7761    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StmtIpyEscapeCommand, ()> {
7762        match node {
7763            AnyRootNodeRef::Stmt(Stmt::IpyEscapeCommand(node)) => Ok(node),
7764            _ => Err(()),
7765        }
7766    }
7767}
7768
7769impl<'a> From<&'a Expr> for AnyRootNodeRef<'a> {
7770    fn from(node: &'a Expr) -> AnyRootNodeRef<'a> {
7771        AnyRootNodeRef::Expr(node)
7772    }
7773}
7774
7775impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a Expr {
7776    type Error = ();
7777    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a Expr, ()> {
7778        match node {
7779            AnyRootNodeRef::Expr(node) => Ok(node),
7780            _ => Err(()),
7781        }
7782    }
7783}
7784
7785impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprBoolOp {
7786    type Error = ();
7787    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprBoolOp, ()> {
7788        match node {
7789            AnyRootNodeRef::Expr(Expr::BoolOp(node)) => Ok(node),
7790            _ => Err(()),
7791        }
7792    }
7793}
7794
7795impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprNamed {
7796    type Error = ();
7797    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprNamed, ()> {
7798        match node {
7799            AnyRootNodeRef::Expr(Expr::Named(node)) => Ok(node),
7800            _ => Err(()),
7801        }
7802    }
7803}
7804
7805impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprBinOp {
7806    type Error = ();
7807    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprBinOp, ()> {
7808        match node {
7809            AnyRootNodeRef::Expr(Expr::BinOp(node)) => Ok(node),
7810            _ => Err(()),
7811        }
7812    }
7813}
7814
7815impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprUnaryOp {
7816    type Error = ();
7817    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprUnaryOp, ()> {
7818        match node {
7819            AnyRootNodeRef::Expr(Expr::UnaryOp(node)) => Ok(node),
7820            _ => Err(()),
7821        }
7822    }
7823}
7824
7825impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprLambda {
7826    type Error = ();
7827    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprLambda, ()> {
7828        match node {
7829            AnyRootNodeRef::Expr(Expr::Lambda(node)) => Ok(node),
7830            _ => Err(()),
7831        }
7832    }
7833}
7834
7835impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprIf {
7836    type Error = ();
7837    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprIf, ()> {
7838        match node {
7839            AnyRootNodeRef::Expr(Expr::If(node)) => Ok(node),
7840            _ => Err(()),
7841        }
7842    }
7843}
7844
7845impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprDict {
7846    type Error = ();
7847    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprDict, ()> {
7848        match node {
7849            AnyRootNodeRef::Expr(Expr::Dict(node)) => Ok(node),
7850            _ => Err(()),
7851        }
7852    }
7853}
7854
7855impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprSet {
7856    type Error = ();
7857    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprSet, ()> {
7858        match node {
7859            AnyRootNodeRef::Expr(Expr::Set(node)) => Ok(node),
7860            _ => Err(()),
7861        }
7862    }
7863}
7864
7865impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprListComp {
7866    type Error = ();
7867    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprListComp, ()> {
7868        match node {
7869            AnyRootNodeRef::Expr(Expr::ListComp(node)) => Ok(node),
7870            _ => Err(()),
7871        }
7872    }
7873}
7874
7875impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprSetComp {
7876    type Error = ();
7877    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprSetComp, ()> {
7878        match node {
7879            AnyRootNodeRef::Expr(Expr::SetComp(node)) => Ok(node),
7880            _ => Err(()),
7881        }
7882    }
7883}
7884
7885impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprDictComp {
7886    type Error = ();
7887    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprDictComp, ()> {
7888        match node {
7889            AnyRootNodeRef::Expr(Expr::DictComp(node)) => Ok(node),
7890            _ => Err(()),
7891        }
7892    }
7893}
7894
7895impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprGenerator {
7896    type Error = ();
7897    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprGenerator, ()> {
7898        match node {
7899            AnyRootNodeRef::Expr(Expr::Generator(node)) => Ok(node),
7900            _ => Err(()),
7901        }
7902    }
7903}
7904
7905impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprAwait {
7906    type Error = ();
7907    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprAwait, ()> {
7908        match node {
7909            AnyRootNodeRef::Expr(Expr::Await(node)) => Ok(node),
7910            _ => Err(()),
7911        }
7912    }
7913}
7914
7915impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprYield {
7916    type Error = ();
7917    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprYield, ()> {
7918        match node {
7919            AnyRootNodeRef::Expr(Expr::Yield(node)) => Ok(node),
7920            _ => Err(()),
7921        }
7922    }
7923}
7924
7925impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprYieldFrom {
7926    type Error = ();
7927    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprYieldFrom, ()> {
7928        match node {
7929            AnyRootNodeRef::Expr(Expr::YieldFrom(node)) => Ok(node),
7930            _ => Err(()),
7931        }
7932    }
7933}
7934
7935impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprCompare {
7936    type Error = ();
7937    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprCompare, ()> {
7938        match node {
7939            AnyRootNodeRef::Expr(Expr::Compare(node)) => Ok(node),
7940            _ => Err(()),
7941        }
7942    }
7943}
7944
7945impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprCall {
7946    type Error = ();
7947    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprCall, ()> {
7948        match node {
7949            AnyRootNodeRef::Expr(Expr::Call(node)) => Ok(node),
7950            _ => Err(()),
7951        }
7952    }
7953}
7954
7955impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprFString {
7956    type Error = ();
7957    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprFString, ()> {
7958        match node {
7959            AnyRootNodeRef::Expr(Expr::FString(node)) => Ok(node),
7960            _ => Err(()),
7961        }
7962    }
7963}
7964
7965impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprTString {
7966    type Error = ();
7967    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprTString, ()> {
7968        match node {
7969            AnyRootNodeRef::Expr(Expr::TString(node)) => Ok(node),
7970            _ => Err(()),
7971        }
7972    }
7973}
7974
7975impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprStringLiteral {
7976    type Error = ();
7977    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprStringLiteral, ()> {
7978        match node {
7979            AnyRootNodeRef::Expr(Expr::StringLiteral(node)) => Ok(node),
7980            _ => Err(()),
7981        }
7982    }
7983}
7984
7985impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprBytesLiteral {
7986    type Error = ();
7987    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprBytesLiteral, ()> {
7988        match node {
7989            AnyRootNodeRef::Expr(Expr::BytesLiteral(node)) => Ok(node),
7990            _ => Err(()),
7991        }
7992    }
7993}
7994
7995impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprNumberLiteral {
7996    type Error = ();
7997    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprNumberLiteral, ()> {
7998        match node {
7999            AnyRootNodeRef::Expr(Expr::NumberLiteral(node)) => Ok(node),
8000            _ => Err(()),
8001        }
8002    }
8003}
8004
8005impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprBooleanLiteral {
8006    type Error = ();
8007    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprBooleanLiteral, ()> {
8008        match node {
8009            AnyRootNodeRef::Expr(Expr::BooleanLiteral(node)) => Ok(node),
8010            _ => Err(()),
8011        }
8012    }
8013}
8014
8015impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprNoneLiteral {
8016    type Error = ();
8017    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprNoneLiteral, ()> {
8018        match node {
8019            AnyRootNodeRef::Expr(Expr::NoneLiteral(node)) => Ok(node),
8020            _ => Err(()),
8021        }
8022    }
8023}
8024
8025impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprEllipsisLiteral {
8026    type Error = ();
8027    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprEllipsisLiteral, ()> {
8028        match node {
8029            AnyRootNodeRef::Expr(Expr::EllipsisLiteral(node)) => Ok(node),
8030            _ => Err(()),
8031        }
8032    }
8033}
8034
8035impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprAttribute {
8036    type Error = ();
8037    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprAttribute, ()> {
8038        match node {
8039            AnyRootNodeRef::Expr(Expr::Attribute(node)) => Ok(node),
8040            _ => Err(()),
8041        }
8042    }
8043}
8044
8045impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprSubscript {
8046    type Error = ();
8047    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprSubscript, ()> {
8048        match node {
8049            AnyRootNodeRef::Expr(Expr::Subscript(node)) => Ok(node),
8050            _ => Err(()),
8051        }
8052    }
8053}
8054
8055impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprStarred {
8056    type Error = ();
8057    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprStarred, ()> {
8058        match node {
8059            AnyRootNodeRef::Expr(Expr::Starred(node)) => Ok(node),
8060            _ => Err(()),
8061        }
8062    }
8063}
8064
8065impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprName {
8066    type Error = ();
8067    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprName, ()> {
8068        match node {
8069            AnyRootNodeRef::Expr(Expr::Name(node)) => Ok(node),
8070            _ => Err(()),
8071        }
8072    }
8073}
8074
8075impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprList {
8076    type Error = ();
8077    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprList, ()> {
8078        match node {
8079            AnyRootNodeRef::Expr(Expr::List(node)) => Ok(node),
8080            _ => Err(()),
8081        }
8082    }
8083}
8084
8085impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprTuple {
8086    type Error = ();
8087    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprTuple, ()> {
8088        match node {
8089            AnyRootNodeRef::Expr(Expr::Tuple(node)) => Ok(node),
8090            _ => Err(()),
8091        }
8092    }
8093}
8094
8095impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprSlice {
8096    type Error = ();
8097    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprSlice, ()> {
8098        match node {
8099            AnyRootNodeRef::Expr(Expr::Slice(node)) => Ok(node),
8100            _ => Err(()),
8101        }
8102    }
8103}
8104
8105impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExprIpyEscapeCommand {
8106    type Error = ();
8107    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprIpyEscapeCommand, ()> {
8108        match node {
8109            AnyRootNodeRef::Expr(Expr::IpyEscapeCommand(node)) => Ok(node),
8110            _ => Err(()),
8111        }
8112    }
8113}
8114
8115impl<'a> From<&'a ExceptHandler> for AnyRootNodeRef<'a> {
8116    fn from(node: &'a ExceptHandler) -> AnyRootNodeRef<'a> {
8117        AnyRootNodeRef::ExceptHandler(node)
8118    }
8119}
8120
8121impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a ExceptHandler {
8122    type Error = ();
8123    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a ExceptHandler, ()> {
8124        match node {
8125            AnyRootNodeRef::ExceptHandler(node) => Ok(node),
8126            _ => Err(()),
8127        }
8128    }
8129}
8130
8131impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ExceptHandlerExceptHandler {
8132    type Error = ();
8133    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExceptHandlerExceptHandler, ()> {
8134        match node {
8135            AnyRootNodeRef::ExceptHandler(ExceptHandler::ExceptHandler(node)) => Ok(node),
8136            _ => Err(()),
8137        }
8138    }
8139}
8140
8141impl<'a> From<&'a InterpolatedStringElement> for AnyRootNodeRef<'a> {
8142    fn from(node: &'a InterpolatedStringElement) -> AnyRootNodeRef<'a> {
8143        AnyRootNodeRef::InterpolatedStringElement(node)
8144    }
8145}
8146
8147impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a InterpolatedStringElement {
8148    type Error = ();
8149    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a InterpolatedStringElement, ()> {
8150        match node {
8151            AnyRootNodeRef::InterpolatedStringElement(node) => Ok(node),
8152            _ => Err(()),
8153        }
8154    }
8155}
8156
8157impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::InterpolatedElement {
8158    type Error = ();
8159    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::InterpolatedElement, ()> {
8160        match node {
8161            AnyRootNodeRef::InterpolatedStringElement(
8162                InterpolatedStringElement::Interpolation(node),
8163            ) => Ok(node),
8164            _ => Err(()),
8165        }
8166    }
8167}
8168
8169impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::InterpolatedStringLiteralElement {
8170    type Error = ();
8171    fn try_from(
8172        node: AnyRootNodeRef<'a>,
8173    ) -> Result<&'a crate::InterpolatedStringLiteralElement, ()> {
8174        match node {
8175            AnyRootNodeRef::InterpolatedStringElement(InterpolatedStringElement::Literal(node)) => {
8176                Ok(node)
8177            }
8178            _ => Err(()),
8179        }
8180    }
8181}
8182
8183impl<'a> From<&'a Pattern> for AnyRootNodeRef<'a> {
8184    fn from(node: &'a Pattern) -> AnyRootNodeRef<'a> {
8185        AnyRootNodeRef::Pattern(node)
8186    }
8187}
8188
8189impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a Pattern {
8190    type Error = ();
8191    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a Pattern, ()> {
8192        match node {
8193            AnyRootNodeRef::Pattern(node) => Ok(node),
8194            _ => Err(()),
8195        }
8196    }
8197}
8198
8199impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::PatternMatchValue {
8200    type Error = ();
8201    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::PatternMatchValue, ()> {
8202        match node {
8203            AnyRootNodeRef::Pattern(Pattern::MatchValue(node)) => Ok(node),
8204            _ => Err(()),
8205        }
8206    }
8207}
8208
8209impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::PatternMatchSingleton {
8210    type Error = ();
8211    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::PatternMatchSingleton, ()> {
8212        match node {
8213            AnyRootNodeRef::Pattern(Pattern::MatchSingleton(node)) => Ok(node),
8214            _ => Err(()),
8215        }
8216    }
8217}
8218
8219impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::PatternMatchSequence {
8220    type Error = ();
8221    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::PatternMatchSequence, ()> {
8222        match node {
8223            AnyRootNodeRef::Pattern(Pattern::MatchSequence(node)) => Ok(node),
8224            _ => Err(()),
8225        }
8226    }
8227}
8228
8229impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::PatternMatchMapping {
8230    type Error = ();
8231    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::PatternMatchMapping, ()> {
8232        match node {
8233            AnyRootNodeRef::Pattern(Pattern::MatchMapping(node)) => Ok(node),
8234            _ => Err(()),
8235        }
8236    }
8237}
8238
8239impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::PatternMatchClass {
8240    type Error = ();
8241    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::PatternMatchClass, ()> {
8242        match node {
8243            AnyRootNodeRef::Pattern(Pattern::MatchClass(node)) => Ok(node),
8244            _ => Err(()),
8245        }
8246    }
8247}
8248
8249impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::PatternMatchStar {
8250    type Error = ();
8251    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::PatternMatchStar, ()> {
8252        match node {
8253            AnyRootNodeRef::Pattern(Pattern::MatchStar(node)) => Ok(node),
8254            _ => Err(()),
8255        }
8256    }
8257}
8258
8259impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::PatternMatchAs {
8260    type Error = ();
8261    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::PatternMatchAs, ()> {
8262        match node {
8263            AnyRootNodeRef::Pattern(Pattern::MatchAs(node)) => Ok(node),
8264            _ => Err(()),
8265        }
8266    }
8267}
8268
8269impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::PatternMatchOr {
8270    type Error = ();
8271    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::PatternMatchOr, ()> {
8272        match node {
8273            AnyRootNodeRef::Pattern(Pattern::MatchOr(node)) => Ok(node),
8274            _ => Err(()),
8275        }
8276    }
8277}
8278
8279impl<'a> From<&'a TypeParam> for AnyRootNodeRef<'a> {
8280    fn from(node: &'a TypeParam) -> AnyRootNodeRef<'a> {
8281        AnyRootNodeRef::TypeParam(node)
8282    }
8283}
8284
8285impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a TypeParam {
8286    type Error = ();
8287    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a TypeParam, ()> {
8288        match node {
8289            AnyRootNodeRef::TypeParam(node) => Ok(node),
8290            _ => Err(()),
8291        }
8292    }
8293}
8294
8295impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::TypeParamTypeVar {
8296    type Error = ();
8297    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::TypeParamTypeVar, ()> {
8298        match node {
8299            AnyRootNodeRef::TypeParam(TypeParam::TypeVar(node)) => Ok(node),
8300            _ => Err(()),
8301        }
8302    }
8303}
8304
8305impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::TypeParamTypeVarTuple {
8306    type Error = ();
8307    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::TypeParamTypeVarTuple, ()> {
8308        match node {
8309            AnyRootNodeRef::TypeParam(TypeParam::TypeVarTuple(node)) => Ok(node),
8310            _ => Err(()),
8311        }
8312    }
8313}
8314
8315impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::TypeParamParamSpec {
8316    type Error = ();
8317    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::TypeParamParamSpec, ()> {
8318        match node {
8319            AnyRootNodeRef::TypeParam(TypeParam::ParamSpec(node)) => Ok(node),
8320            _ => Err(()),
8321        }
8322    }
8323}
8324
8325impl<'a> From<&'a crate::InterpolatedStringFormatSpec> for AnyRootNodeRef<'a> {
8326    fn from(node: &'a crate::InterpolatedStringFormatSpec) -> AnyRootNodeRef<'a> {
8327        AnyRootNodeRef::InterpolatedStringFormatSpec(node)
8328    }
8329}
8330
8331impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::InterpolatedStringFormatSpec {
8332    type Error = ();
8333    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::InterpolatedStringFormatSpec, ()> {
8334        match node {
8335            AnyRootNodeRef::InterpolatedStringFormatSpec(node) => Ok(node),
8336            _ => Err(()),
8337        }
8338    }
8339}
8340
8341impl<'a> From<&'a crate::PatternArguments> for AnyRootNodeRef<'a> {
8342    fn from(node: &'a crate::PatternArguments) -> AnyRootNodeRef<'a> {
8343        AnyRootNodeRef::PatternArguments(node)
8344    }
8345}
8346
8347impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::PatternArguments {
8348    type Error = ();
8349    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::PatternArguments, ()> {
8350        match node {
8351            AnyRootNodeRef::PatternArguments(node) => Ok(node),
8352            _ => Err(()),
8353        }
8354    }
8355}
8356
8357impl<'a> From<&'a crate::PatternKeyword> for AnyRootNodeRef<'a> {
8358    fn from(node: &'a crate::PatternKeyword) -> AnyRootNodeRef<'a> {
8359        AnyRootNodeRef::PatternKeyword(node)
8360    }
8361}
8362
8363impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::PatternKeyword {
8364    type Error = ();
8365    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::PatternKeyword, ()> {
8366        match node {
8367            AnyRootNodeRef::PatternKeyword(node) => Ok(node),
8368            _ => Err(()),
8369        }
8370    }
8371}
8372
8373impl<'a> From<&'a crate::Comprehension> for AnyRootNodeRef<'a> {
8374    fn from(node: &'a crate::Comprehension) -> AnyRootNodeRef<'a> {
8375        AnyRootNodeRef::Comprehension(node)
8376    }
8377}
8378
8379impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::Comprehension {
8380    type Error = ();
8381    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::Comprehension, ()> {
8382        match node {
8383            AnyRootNodeRef::Comprehension(node) => Ok(node),
8384            _ => Err(()),
8385        }
8386    }
8387}
8388
8389impl<'a> From<&'a crate::Arguments> for AnyRootNodeRef<'a> {
8390    fn from(node: &'a crate::Arguments) -> AnyRootNodeRef<'a> {
8391        AnyRootNodeRef::Arguments(node)
8392    }
8393}
8394
8395impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::Arguments {
8396    type Error = ();
8397    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::Arguments, ()> {
8398        match node {
8399            AnyRootNodeRef::Arguments(node) => Ok(node),
8400            _ => Err(()),
8401        }
8402    }
8403}
8404
8405impl<'a> From<&'a crate::Parameters> for AnyRootNodeRef<'a> {
8406    fn from(node: &'a crate::Parameters) -> AnyRootNodeRef<'a> {
8407        AnyRootNodeRef::Parameters(node)
8408    }
8409}
8410
8411impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::Parameters {
8412    type Error = ();
8413    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::Parameters, ()> {
8414        match node {
8415            AnyRootNodeRef::Parameters(node) => Ok(node),
8416            _ => Err(()),
8417        }
8418    }
8419}
8420
8421impl<'a> From<&'a crate::Parameter> for AnyRootNodeRef<'a> {
8422    fn from(node: &'a crate::Parameter) -> AnyRootNodeRef<'a> {
8423        AnyRootNodeRef::Parameter(node)
8424    }
8425}
8426
8427impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::Parameter {
8428    type Error = ();
8429    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::Parameter, ()> {
8430        match node {
8431            AnyRootNodeRef::Parameter(node) => Ok(node),
8432            _ => Err(()),
8433        }
8434    }
8435}
8436
8437impl<'a> From<&'a crate::ParameterWithDefault> for AnyRootNodeRef<'a> {
8438    fn from(node: &'a crate::ParameterWithDefault) -> AnyRootNodeRef<'a> {
8439        AnyRootNodeRef::ParameterWithDefault(node)
8440    }
8441}
8442
8443impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ParameterWithDefault {
8444    type Error = ();
8445    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ParameterWithDefault, ()> {
8446        match node {
8447            AnyRootNodeRef::ParameterWithDefault(node) => Ok(node),
8448            _ => Err(()),
8449        }
8450    }
8451}
8452
8453impl<'a> From<&'a crate::Keyword> for AnyRootNodeRef<'a> {
8454    fn from(node: &'a crate::Keyword) -> AnyRootNodeRef<'a> {
8455        AnyRootNodeRef::Keyword(node)
8456    }
8457}
8458
8459impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::Keyword {
8460    type Error = ();
8461    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::Keyword, ()> {
8462        match node {
8463            AnyRootNodeRef::Keyword(node) => Ok(node),
8464            _ => Err(()),
8465        }
8466    }
8467}
8468
8469impl<'a> From<&'a crate::Alias> for AnyRootNodeRef<'a> {
8470    fn from(node: &'a crate::Alias) -> AnyRootNodeRef<'a> {
8471        AnyRootNodeRef::Alias(node)
8472    }
8473}
8474
8475impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::Alias {
8476    type Error = ();
8477    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::Alias, ()> {
8478        match node {
8479            AnyRootNodeRef::Alias(node) => Ok(node),
8480            _ => Err(()),
8481        }
8482    }
8483}
8484
8485impl<'a> From<&'a crate::WithItem> for AnyRootNodeRef<'a> {
8486    fn from(node: &'a crate::WithItem) -> AnyRootNodeRef<'a> {
8487        AnyRootNodeRef::WithItem(node)
8488    }
8489}
8490
8491impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::WithItem {
8492    type Error = ();
8493    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::WithItem, ()> {
8494        match node {
8495            AnyRootNodeRef::WithItem(node) => Ok(node),
8496            _ => Err(()),
8497        }
8498    }
8499}
8500
8501impl<'a> From<&'a crate::MatchCase> for AnyRootNodeRef<'a> {
8502    fn from(node: &'a crate::MatchCase) -> AnyRootNodeRef<'a> {
8503        AnyRootNodeRef::MatchCase(node)
8504    }
8505}
8506
8507impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::MatchCase {
8508    type Error = ();
8509    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::MatchCase, ()> {
8510        match node {
8511            AnyRootNodeRef::MatchCase(node) => Ok(node),
8512            _ => Err(()),
8513        }
8514    }
8515}
8516
8517impl<'a> From<&'a crate::Decorator> for AnyRootNodeRef<'a> {
8518    fn from(node: &'a crate::Decorator) -> AnyRootNodeRef<'a> {
8519        AnyRootNodeRef::Decorator(node)
8520    }
8521}
8522
8523impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::Decorator {
8524    type Error = ();
8525    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::Decorator, ()> {
8526        match node {
8527            AnyRootNodeRef::Decorator(node) => Ok(node),
8528            _ => Err(()),
8529        }
8530    }
8531}
8532
8533impl<'a> From<&'a crate::ElifElseClause> for AnyRootNodeRef<'a> {
8534    fn from(node: &'a crate::ElifElseClause) -> AnyRootNodeRef<'a> {
8535        AnyRootNodeRef::ElifElseClause(node)
8536    }
8537}
8538
8539impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::ElifElseClause {
8540    type Error = ();
8541    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ElifElseClause, ()> {
8542        match node {
8543            AnyRootNodeRef::ElifElseClause(node) => Ok(node),
8544            _ => Err(()),
8545        }
8546    }
8547}
8548
8549impl<'a> From<&'a crate::TypeParams> for AnyRootNodeRef<'a> {
8550    fn from(node: &'a crate::TypeParams) -> AnyRootNodeRef<'a> {
8551        AnyRootNodeRef::TypeParams(node)
8552    }
8553}
8554
8555impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::TypeParams {
8556    type Error = ();
8557    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::TypeParams, ()> {
8558        match node {
8559            AnyRootNodeRef::TypeParams(node) => Ok(node),
8560            _ => Err(()),
8561        }
8562    }
8563}
8564
8565impl<'a> From<&'a crate::FString> for AnyRootNodeRef<'a> {
8566    fn from(node: &'a crate::FString) -> AnyRootNodeRef<'a> {
8567        AnyRootNodeRef::FString(node)
8568    }
8569}
8570
8571impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::FString {
8572    type Error = ();
8573    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::FString, ()> {
8574        match node {
8575            AnyRootNodeRef::FString(node) => Ok(node),
8576            _ => Err(()),
8577        }
8578    }
8579}
8580
8581impl<'a> From<&'a crate::TString> for AnyRootNodeRef<'a> {
8582    fn from(node: &'a crate::TString) -> AnyRootNodeRef<'a> {
8583        AnyRootNodeRef::TString(node)
8584    }
8585}
8586
8587impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::TString {
8588    type Error = ();
8589    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::TString, ()> {
8590        match node {
8591            AnyRootNodeRef::TString(node) => Ok(node),
8592            _ => Err(()),
8593        }
8594    }
8595}
8596
8597impl<'a> From<&'a crate::StringLiteral> for AnyRootNodeRef<'a> {
8598    fn from(node: &'a crate::StringLiteral) -> AnyRootNodeRef<'a> {
8599        AnyRootNodeRef::StringLiteral(node)
8600    }
8601}
8602
8603impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::StringLiteral {
8604    type Error = ();
8605    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::StringLiteral, ()> {
8606        match node {
8607            AnyRootNodeRef::StringLiteral(node) => Ok(node),
8608            _ => Err(()),
8609        }
8610    }
8611}
8612
8613impl<'a> From<&'a crate::BytesLiteral> for AnyRootNodeRef<'a> {
8614    fn from(node: &'a crate::BytesLiteral) -> AnyRootNodeRef<'a> {
8615        AnyRootNodeRef::BytesLiteral(node)
8616    }
8617}
8618
8619impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::BytesLiteral {
8620    type Error = ();
8621    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::BytesLiteral, ()> {
8622        match node {
8623            AnyRootNodeRef::BytesLiteral(node) => Ok(node),
8624            _ => Err(()),
8625        }
8626    }
8627}
8628
8629impl<'a> From<&'a crate::Identifier> for AnyRootNodeRef<'a> {
8630    fn from(node: &'a crate::Identifier) -> AnyRootNodeRef<'a> {
8631        AnyRootNodeRef::Identifier(node)
8632    }
8633}
8634
8635impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a crate::Identifier {
8636    type Error = ();
8637    fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::Identifier, ()> {
8638        match node {
8639            AnyRootNodeRef::Identifier(node) => Ok(node),
8640            _ => Err(()),
8641        }
8642    }
8643}
8644
8645impl ruff_text_size::Ranged for AnyRootNodeRef<'_> {
8646    fn range(&self) -> ruff_text_size::TextRange {
8647        match self {
8648            AnyRootNodeRef::Mod(node) => node.range(),
8649            AnyRootNodeRef::Stmt(node) => node.range(),
8650            AnyRootNodeRef::Expr(node) => node.range(),
8651            AnyRootNodeRef::ExceptHandler(node) => node.range(),
8652            AnyRootNodeRef::InterpolatedStringElement(node) => node.range(),
8653            AnyRootNodeRef::Pattern(node) => node.range(),
8654            AnyRootNodeRef::TypeParam(node) => node.range(),
8655            AnyRootNodeRef::InterpolatedStringFormatSpec(node) => node.range(),
8656            AnyRootNodeRef::PatternArguments(node) => node.range(),
8657            AnyRootNodeRef::PatternKeyword(node) => node.range(),
8658            AnyRootNodeRef::Comprehension(node) => node.range(),
8659            AnyRootNodeRef::Arguments(node) => node.range(),
8660            AnyRootNodeRef::Parameters(node) => node.range(),
8661            AnyRootNodeRef::Parameter(node) => node.range(),
8662            AnyRootNodeRef::ParameterWithDefault(node) => node.range(),
8663            AnyRootNodeRef::Keyword(node) => node.range(),
8664            AnyRootNodeRef::Alias(node) => node.range(),
8665            AnyRootNodeRef::WithItem(node) => node.range(),
8666            AnyRootNodeRef::MatchCase(node) => node.range(),
8667            AnyRootNodeRef::Decorator(node) => node.range(),
8668            AnyRootNodeRef::ElifElseClause(node) => node.range(),
8669            AnyRootNodeRef::TypeParams(node) => node.range(),
8670            AnyRootNodeRef::FString(node) => node.range(),
8671            AnyRootNodeRef::TString(node) => node.range(),
8672            AnyRootNodeRef::StringLiteral(node) => node.range(),
8673            AnyRootNodeRef::BytesLiteral(node) => node.range(),
8674            AnyRootNodeRef::Identifier(node) => node.range(),
8675        }
8676    }
8677}
8678
8679impl crate::HasNodeIndex for AnyRootNodeRef<'_> {
8680    fn node_index(&self) -> &crate::AtomicNodeIndex {
8681        match self {
8682            AnyRootNodeRef::Mod(node) => node.node_index(),
8683            AnyRootNodeRef::Stmt(node) => node.node_index(),
8684            AnyRootNodeRef::Expr(node) => node.node_index(),
8685            AnyRootNodeRef::ExceptHandler(node) => node.node_index(),
8686            AnyRootNodeRef::InterpolatedStringElement(node) => node.node_index(),
8687            AnyRootNodeRef::Pattern(node) => node.node_index(),
8688            AnyRootNodeRef::TypeParam(node) => node.node_index(),
8689            AnyRootNodeRef::InterpolatedStringFormatSpec(node) => node.node_index(),
8690            AnyRootNodeRef::PatternArguments(node) => node.node_index(),
8691            AnyRootNodeRef::PatternKeyword(node) => node.node_index(),
8692            AnyRootNodeRef::Comprehension(node) => node.node_index(),
8693            AnyRootNodeRef::Arguments(node) => node.node_index(),
8694            AnyRootNodeRef::Parameters(node) => node.node_index(),
8695            AnyRootNodeRef::Parameter(node) => node.node_index(),
8696            AnyRootNodeRef::ParameterWithDefault(node) => node.node_index(),
8697            AnyRootNodeRef::Keyword(node) => node.node_index(),
8698            AnyRootNodeRef::Alias(node) => node.node_index(),
8699            AnyRootNodeRef::WithItem(node) => node.node_index(),
8700            AnyRootNodeRef::MatchCase(node) => node.node_index(),
8701            AnyRootNodeRef::Decorator(node) => node.node_index(),
8702            AnyRootNodeRef::ElifElseClause(node) => node.node_index(),
8703            AnyRootNodeRef::TypeParams(node) => node.node_index(),
8704            AnyRootNodeRef::FString(node) => node.node_index(),
8705            AnyRootNodeRef::TString(node) => node.node_index(),
8706            AnyRootNodeRef::StringLiteral(node) => node.node_index(),
8707            AnyRootNodeRef::BytesLiteral(node) => node.node_index(),
8708            AnyRootNodeRef::Identifier(node) => node.node_index(),
8709        }
8710    }
8711}
8712
8713impl<'a> AnyRootNodeRef<'a> {
8714    pub fn visit_source_order<'b, V>(self, visitor: &mut V)
8715    where
8716        V: crate::visitor::source_order::SourceOrderVisitor<'b> + ?Sized,
8717        'a: 'b,
8718    {
8719        match self {
8720            AnyRootNodeRef::Mod(node) => node.visit_source_order(visitor),
8721            AnyRootNodeRef::Stmt(node) => node.visit_source_order(visitor),
8722            AnyRootNodeRef::Expr(node) => node.visit_source_order(visitor),
8723            AnyRootNodeRef::ExceptHandler(node) => node.visit_source_order(visitor),
8724            AnyRootNodeRef::InterpolatedStringElement(node) => node.visit_source_order(visitor),
8725            AnyRootNodeRef::Pattern(node) => node.visit_source_order(visitor),
8726            AnyRootNodeRef::TypeParam(node) => node.visit_source_order(visitor),
8727            AnyRootNodeRef::InterpolatedStringFormatSpec(node) => node.visit_source_order(visitor),
8728            AnyRootNodeRef::PatternArguments(node) => node.visit_source_order(visitor),
8729            AnyRootNodeRef::PatternKeyword(node) => node.visit_source_order(visitor),
8730            AnyRootNodeRef::Comprehension(node) => node.visit_source_order(visitor),
8731            AnyRootNodeRef::Arguments(node) => node.visit_source_order(visitor),
8732            AnyRootNodeRef::Parameters(node) => node.visit_source_order(visitor),
8733            AnyRootNodeRef::Parameter(node) => node.visit_source_order(visitor),
8734            AnyRootNodeRef::ParameterWithDefault(node) => node.visit_source_order(visitor),
8735            AnyRootNodeRef::Keyword(node) => node.visit_source_order(visitor),
8736            AnyRootNodeRef::Alias(node) => node.visit_source_order(visitor),
8737            AnyRootNodeRef::WithItem(node) => node.visit_source_order(visitor),
8738            AnyRootNodeRef::MatchCase(node) => node.visit_source_order(visitor),
8739            AnyRootNodeRef::Decorator(node) => node.visit_source_order(visitor),
8740            AnyRootNodeRef::ElifElseClause(node) => node.visit_source_order(visitor),
8741            AnyRootNodeRef::TypeParams(node) => node.visit_source_order(visitor),
8742            AnyRootNodeRef::FString(node) => node.visit_source_order(visitor),
8743            AnyRootNodeRef::TString(node) => node.visit_source_order(visitor),
8744            AnyRootNodeRef::StringLiteral(node) => node.visit_source_order(visitor),
8745            AnyRootNodeRef::BytesLiteral(node) => node.visit_source_order(visitor),
8746            AnyRootNodeRef::Identifier(node) => node.visit_source_order(visitor),
8747        }
8748    }
8749}
8750
8751#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
8752pub enum NodeKind {
8753    ModModule,
8754    ModExpression,
8755    StmtFunctionDef,
8756    StmtClassDef,
8757    StmtReturn,
8758    StmtDelete,
8759    StmtTypeAlias,
8760    StmtAssign,
8761    StmtAugAssign,
8762    StmtAnnAssign,
8763    StmtFor,
8764    StmtWhile,
8765    StmtIf,
8766    StmtWith,
8767    StmtMatch,
8768    StmtRaise,
8769    StmtTry,
8770    StmtAssert,
8771    StmtImport,
8772    StmtImportFrom,
8773    StmtGlobal,
8774    StmtNonlocal,
8775    StmtExpr,
8776    StmtPass,
8777    StmtBreak,
8778    StmtContinue,
8779    StmtIpyEscapeCommand,
8780    ExprBoolOp,
8781    ExprNamed,
8782    ExprBinOp,
8783    ExprUnaryOp,
8784    ExprLambda,
8785    ExprIf,
8786    ExprDict,
8787    ExprSet,
8788    ExprListComp,
8789    ExprSetComp,
8790    ExprDictComp,
8791    ExprGenerator,
8792    ExprAwait,
8793    ExprYield,
8794    ExprYieldFrom,
8795    ExprCompare,
8796    ExprCall,
8797    ExprFString,
8798    ExprTString,
8799    ExprStringLiteral,
8800    ExprBytesLiteral,
8801    ExprNumberLiteral,
8802    ExprBooleanLiteral,
8803    ExprNoneLiteral,
8804    ExprEllipsisLiteral,
8805    ExprAttribute,
8806    ExprSubscript,
8807    ExprStarred,
8808    ExprName,
8809    ExprList,
8810    ExprTuple,
8811    ExprSlice,
8812    ExprIpyEscapeCommand,
8813    ExceptHandlerExceptHandler,
8814    InterpolatedElement,
8815    InterpolatedStringLiteralElement,
8816    PatternMatchValue,
8817    PatternMatchSingleton,
8818    PatternMatchSequence,
8819    PatternMatchMapping,
8820    PatternMatchClass,
8821    PatternMatchStar,
8822    PatternMatchAs,
8823    PatternMatchOr,
8824    TypeParamTypeVar,
8825    TypeParamTypeVarTuple,
8826    TypeParamParamSpec,
8827    InterpolatedStringFormatSpec,
8828    PatternArguments,
8829    PatternKeyword,
8830    Comprehension,
8831    Arguments,
8832    Parameters,
8833    Parameter,
8834    ParameterWithDefault,
8835    Keyword,
8836    Alias,
8837    WithItem,
8838    MatchCase,
8839    Decorator,
8840    ElifElseClause,
8841    TypeParams,
8842    FString,
8843    TString,
8844    StringLiteral,
8845    BytesLiteral,
8846    Identifier,
8847}
8848
8849impl AnyNodeRef<'_> {
8850    pub const fn kind(self) -> NodeKind {
8851        match self {
8852            AnyNodeRef::ModModule(_) => NodeKind::ModModule,
8853            AnyNodeRef::ModExpression(_) => NodeKind::ModExpression,
8854            AnyNodeRef::StmtFunctionDef(_) => NodeKind::StmtFunctionDef,
8855            AnyNodeRef::StmtClassDef(_) => NodeKind::StmtClassDef,
8856            AnyNodeRef::StmtReturn(_) => NodeKind::StmtReturn,
8857            AnyNodeRef::StmtDelete(_) => NodeKind::StmtDelete,
8858            AnyNodeRef::StmtTypeAlias(_) => NodeKind::StmtTypeAlias,
8859            AnyNodeRef::StmtAssign(_) => NodeKind::StmtAssign,
8860            AnyNodeRef::StmtAugAssign(_) => NodeKind::StmtAugAssign,
8861            AnyNodeRef::StmtAnnAssign(_) => NodeKind::StmtAnnAssign,
8862            AnyNodeRef::StmtFor(_) => NodeKind::StmtFor,
8863            AnyNodeRef::StmtWhile(_) => NodeKind::StmtWhile,
8864            AnyNodeRef::StmtIf(_) => NodeKind::StmtIf,
8865            AnyNodeRef::StmtWith(_) => NodeKind::StmtWith,
8866            AnyNodeRef::StmtMatch(_) => NodeKind::StmtMatch,
8867            AnyNodeRef::StmtRaise(_) => NodeKind::StmtRaise,
8868            AnyNodeRef::StmtTry(_) => NodeKind::StmtTry,
8869            AnyNodeRef::StmtAssert(_) => NodeKind::StmtAssert,
8870            AnyNodeRef::StmtImport(_) => NodeKind::StmtImport,
8871            AnyNodeRef::StmtImportFrom(_) => NodeKind::StmtImportFrom,
8872            AnyNodeRef::StmtGlobal(_) => NodeKind::StmtGlobal,
8873            AnyNodeRef::StmtNonlocal(_) => NodeKind::StmtNonlocal,
8874            AnyNodeRef::StmtExpr(_) => NodeKind::StmtExpr,
8875            AnyNodeRef::StmtPass(_) => NodeKind::StmtPass,
8876            AnyNodeRef::StmtBreak(_) => NodeKind::StmtBreak,
8877            AnyNodeRef::StmtContinue(_) => NodeKind::StmtContinue,
8878            AnyNodeRef::StmtIpyEscapeCommand(_) => NodeKind::StmtIpyEscapeCommand,
8879            AnyNodeRef::ExprBoolOp(_) => NodeKind::ExprBoolOp,
8880            AnyNodeRef::ExprNamed(_) => NodeKind::ExprNamed,
8881            AnyNodeRef::ExprBinOp(_) => NodeKind::ExprBinOp,
8882            AnyNodeRef::ExprUnaryOp(_) => NodeKind::ExprUnaryOp,
8883            AnyNodeRef::ExprLambda(_) => NodeKind::ExprLambda,
8884            AnyNodeRef::ExprIf(_) => NodeKind::ExprIf,
8885            AnyNodeRef::ExprDict(_) => NodeKind::ExprDict,
8886            AnyNodeRef::ExprSet(_) => NodeKind::ExprSet,
8887            AnyNodeRef::ExprListComp(_) => NodeKind::ExprListComp,
8888            AnyNodeRef::ExprSetComp(_) => NodeKind::ExprSetComp,
8889            AnyNodeRef::ExprDictComp(_) => NodeKind::ExprDictComp,
8890            AnyNodeRef::ExprGenerator(_) => NodeKind::ExprGenerator,
8891            AnyNodeRef::ExprAwait(_) => NodeKind::ExprAwait,
8892            AnyNodeRef::ExprYield(_) => NodeKind::ExprYield,
8893            AnyNodeRef::ExprYieldFrom(_) => NodeKind::ExprYieldFrom,
8894            AnyNodeRef::ExprCompare(_) => NodeKind::ExprCompare,
8895            AnyNodeRef::ExprCall(_) => NodeKind::ExprCall,
8896            AnyNodeRef::ExprFString(_) => NodeKind::ExprFString,
8897            AnyNodeRef::ExprTString(_) => NodeKind::ExprTString,
8898            AnyNodeRef::ExprStringLiteral(_) => NodeKind::ExprStringLiteral,
8899            AnyNodeRef::ExprBytesLiteral(_) => NodeKind::ExprBytesLiteral,
8900            AnyNodeRef::ExprNumberLiteral(_) => NodeKind::ExprNumberLiteral,
8901            AnyNodeRef::ExprBooleanLiteral(_) => NodeKind::ExprBooleanLiteral,
8902            AnyNodeRef::ExprNoneLiteral(_) => NodeKind::ExprNoneLiteral,
8903            AnyNodeRef::ExprEllipsisLiteral(_) => NodeKind::ExprEllipsisLiteral,
8904            AnyNodeRef::ExprAttribute(_) => NodeKind::ExprAttribute,
8905            AnyNodeRef::ExprSubscript(_) => NodeKind::ExprSubscript,
8906            AnyNodeRef::ExprStarred(_) => NodeKind::ExprStarred,
8907            AnyNodeRef::ExprName(_) => NodeKind::ExprName,
8908            AnyNodeRef::ExprList(_) => NodeKind::ExprList,
8909            AnyNodeRef::ExprTuple(_) => NodeKind::ExprTuple,
8910            AnyNodeRef::ExprSlice(_) => NodeKind::ExprSlice,
8911            AnyNodeRef::ExprIpyEscapeCommand(_) => NodeKind::ExprIpyEscapeCommand,
8912            AnyNodeRef::ExceptHandlerExceptHandler(_) => NodeKind::ExceptHandlerExceptHandler,
8913            AnyNodeRef::InterpolatedElement(_) => NodeKind::InterpolatedElement,
8914            AnyNodeRef::InterpolatedStringLiteralElement(_) => {
8915                NodeKind::InterpolatedStringLiteralElement
8916            }
8917            AnyNodeRef::PatternMatchValue(_) => NodeKind::PatternMatchValue,
8918            AnyNodeRef::PatternMatchSingleton(_) => NodeKind::PatternMatchSingleton,
8919            AnyNodeRef::PatternMatchSequence(_) => NodeKind::PatternMatchSequence,
8920            AnyNodeRef::PatternMatchMapping(_) => NodeKind::PatternMatchMapping,
8921            AnyNodeRef::PatternMatchClass(_) => NodeKind::PatternMatchClass,
8922            AnyNodeRef::PatternMatchStar(_) => NodeKind::PatternMatchStar,
8923            AnyNodeRef::PatternMatchAs(_) => NodeKind::PatternMatchAs,
8924            AnyNodeRef::PatternMatchOr(_) => NodeKind::PatternMatchOr,
8925            AnyNodeRef::TypeParamTypeVar(_) => NodeKind::TypeParamTypeVar,
8926            AnyNodeRef::TypeParamTypeVarTuple(_) => NodeKind::TypeParamTypeVarTuple,
8927            AnyNodeRef::TypeParamParamSpec(_) => NodeKind::TypeParamParamSpec,
8928            AnyNodeRef::InterpolatedStringFormatSpec(_) => NodeKind::InterpolatedStringFormatSpec,
8929            AnyNodeRef::PatternArguments(_) => NodeKind::PatternArguments,
8930            AnyNodeRef::PatternKeyword(_) => NodeKind::PatternKeyword,
8931            AnyNodeRef::Comprehension(_) => NodeKind::Comprehension,
8932            AnyNodeRef::Arguments(_) => NodeKind::Arguments,
8933            AnyNodeRef::Parameters(_) => NodeKind::Parameters,
8934            AnyNodeRef::Parameter(_) => NodeKind::Parameter,
8935            AnyNodeRef::ParameterWithDefault(_) => NodeKind::ParameterWithDefault,
8936            AnyNodeRef::Keyword(_) => NodeKind::Keyword,
8937            AnyNodeRef::Alias(_) => NodeKind::Alias,
8938            AnyNodeRef::WithItem(_) => NodeKind::WithItem,
8939            AnyNodeRef::MatchCase(_) => NodeKind::MatchCase,
8940            AnyNodeRef::Decorator(_) => NodeKind::Decorator,
8941            AnyNodeRef::ElifElseClause(_) => NodeKind::ElifElseClause,
8942            AnyNodeRef::TypeParams(_) => NodeKind::TypeParams,
8943            AnyNodeRef::FString(_) => NodeKind::FString,
8944            AnyNodeRef::TString(_) => NodeKind::TString,
8945            AnyNodeRef::StringLiteral(_) => NodeKind::StringLiteral,
8946            AnyNodeRef::BytesLiteral(_) => NodeKind::BytesLiteral,
8947            AnyNodeRef::Identifier(_) => NodeKind::Identifier,
8948        }
8949    }
8950}
8951
8952/// See also [Module](https://docs.python.org/3/library/ast.html#ast.Module)
8953#[derive(Clone, Debug, PartialEq)]
8954#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
8955pub struct ModModule {
8956    pub node_index: crate::AtomicNodeIndex,
8957    pub range: ruff_text_size::TextRange,
8958    pub body: Vec<Stmt>,
8959}
8960
8961/// See also [Module](https://docs.python.org/3/library/ast.html#ast.Module)
8962#[derive(Clone, Debug, PartialEq)]
8963#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
8964pub struct ModExpression {
8965    pub node_index: crate::AtomicNodeIndex,
8966    pub range: ruff_text_size::TextRange,
8967    pub body: Box<Expr>,
8968}
8969
8970/// See also [FunctionDef](https://docs.python.org/3/library/ast.html#ast.FunctionDef)
8971/// and [AsyncFunctionDef](https://docs.python.org/3/library/ast.html#ast.AsyncFunctionDef).
8972///
8973/// This type differs from the original Python AST, as it collapses the synchronous and asynchronous variants into a single type.
8974#[derive(Clone, Debug, PartialEq)]
8975#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
8976pub struct StmtFunctionDef {
8977    pub node_index: crate::AtomicNodeIndex,
8978    pub range: ruff_text_size::TextRange,
8979    pub is_async: bool,
8980    pub decorator_list: Vec<crate::Decorator>,
8981    pub name: crate::Identifier,
8982    pub type_params: Option<Box<crate::TypeParams>>,
8983    pub parameters: Box<crate::Parameters>,
8984    pub returns: Option<Box<Expr>>,
8985    pub body: Vec<Stmt>,
8986}
8987
8988/// See also [ClassDef](https://docs.python.org/3/library/ast.html#ast.ClassDef)
8989#[derive(Clone, Debug, PartialEq)]
8990#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
8991pub struct StmtClassDef {
8992    pub node_index: crate::AtomicNodeIndex,
8993    pub range: ruff_text_size::TextRange,
8994    pub decorator_list: Vec<crate::Decorator>,
8995    pub name: crate::Identifier,
8996    pub type_params: Option<Box<crate::TypeParams>>,
8997    pub arguments: Option<Box<crate::Arguments>>,
8998    pub body: Vec<Stmt>,
8999}
9000
9001/// See also [Return](https://docs.python.org/3/library/ast.html#ast.Return)
9002#[derive(Clone, Debug, PartialEq)]
9003#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9004pub struct StmtReturn {
9005    pub node_index: crate::AtomicNodeIndex,
9006    pub range: ruff_text_size::TextRange,
9007    pub value: Option<Box<Expr>>,
9008}
9009
9010/// See also [Delete](https://docs.python.org/3/library/ast.html#ast.Delete)
9011#[derive(Clone, Debug, PartialEq)]
9012#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9013pub struct StmtDelete {
9014    pub node_index: crate::AtomicNodeIndex,
9015    pub range: ruff_text_size::TextRange,
9016    pub targets: Vec<Expr>,
9017}
9018
9019/// See also [TypeAlias](https://docs.python.org/3/library/ast.html#ast.TypeAlias)
9020#[derive(Clone, Debug, PartialEq)]
9021#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9022pub struct StmtTypeAlias {
9023    pub node_index: crate::AtomicNodeIndex,
9024    pub range: ruff_text_size::TextRange,
9025    pub name: Box<Expr>,
9026    pub type_params: Option<Box<crate::TypeParams>>,
9027    pub value: Box<Expr>,
9028}
9029
9030/// See also [Assign](https://docs.python.org/3/library/ast.html#ast.Assign)
9031#[derive(Clone, Debug, PartialEq)]
9032#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9033pub struct StmtAssign {
9034    pub node_index: crate::AtomicNodeIndex,
9035    pub range: ruff_text_size::TextRange,
9036    pub targets: Vec<Expr>,
9037    pub value: Box<Expr>,
9038}
9039
9040/// See also [AugAssign](https://docs.python.org/3/library/ast.html#ast.AugAssign)
9041#[derive(Clone, Debug, PartialEq)]
9042#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9043pub struct StmtAugAssign {
9044    pub node_index: crate::AtomicNodeIndex,
9045    pub range: ruff_text_size::TextRange,
9046    pub target: Box<Expr>,
9047    pub op: crate::Operator,
9048    pub value: Box<Expr>,
9049}
9050
9051/// See also [AnnAssign](https://docs.python.org/3/library/ast.html#ast.AnnAssign)
9052#[derive(Clone, Debug, PartialEq)]
9053#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9054pub struct StmtAnnAssign {
9055    pub node_index: crate::AtomicNodeIndex,
9056    pub range: ruff_text_size::TextRange,
9057    pub target: Box<Expr>,
9058    pub annotation: Box<Expr>,
9059    pub value: Option<Box<Expr>>,
9060    pub simple: bool,
9061}
9062
9063/// See also [For](https://docs.python.org/3/library/ast.html#ast.For)
9064/// and [AsyncFor](https://docs.python.org/3/library/ast.html#ast.AsyncFor).
9065///
9066/// This type differs from the original Python AST, as it collapses the synchronous and asynchronous variants into a single type.
9067#[derive(Clone, Debug, PartialEq)]
9068#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9069pub struct StmtFor {
9070    pub node_index: crate::AtomicNodeIndex,
9071    pub range: ruff_text_size::TextRange,
9072    pub is_async: bool,
9073    pub target: Box<Expr>,
9074    pub iter: Box<Expr>,
9075    pub body: Vec<Stmt>,
9076    pub orelse: Vec<Stmt>,
9077}
9078
9079/// See also [While](https://docs.python.org/3/library/ast.html#ast.While)
9080/// and [AsyncWhile](https://docs.python.org/3/library/ast.html#ast.AsyncWhile).
9081#[derive(Clone, Debug, PartialEq)]
9082#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9083pub struct StmtWhile {
9084    pub node_index: crate::AtomicNodeIndex,
9085    pub range: ruff_text_size::TextRange,
9086    pub test: Box<Expr>,
9087    pub body: Vec<Stmt>,
9088    pub orelse: Vec<Stmt>,
9089}
9090
9091/// See also [If](https://docs.python.org/3/library/ast.html#ast.If)
9092#[derive(Clone, Debug, PartialEq)]
9093#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9094pub struct StmtIf {
9095    pub node_index: crate::AtomicNodeIndex,
9096    pub range: ruff_text_size::TextRange,
9097    pub test: Box<Expr>,
9098    pub body: Vec<Stmt>,
9099    pub elif_else_clauses: Vec<crate::ElifElseClause>,
9100}
9101
9102/// See also [With](https://docs.python.org/3/library/ast.html#ast.With)
9103/// and [AsyncWith](https://docs.python.org/3/library/ast.html#ast.AsyncWith).
9104///
9105/// This type differs from the original Python AST, as it collapses the synchronous and asynchronous variants into a single type.
9106#[derive(Clone, Debug, PartialEq)]
9107#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9108pub struct StmtWith {
9109    pub node_index: crate::AtomicNodeIndex,
9110    pub range: ruff_text_size::TextRange,
9111    pub is_async: bool,
9112    pub items: Vec<crate::WithItem>,
9113    pub body: Vec<Stmt>,
9114}
9115
9116/// See also [Match](https://docs.python.org/3/library/ast.html#ast.Match)
9117#[derive(Clone, Debug, PartialEq)]
9118#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9119pub struct StmtMatch {
9120    pub node_index: crate::AtomicNodeIndex,
9121    pub range: ruff_text_size::TextRange,
9122    pub subject: Box<Expr>,
9123    pub cases: Vec<crate::MatchCase>,
9124}
9125
9126/// See also [Raise](https://docs.python.org/3/library/ast.html#ast.Raise)
9127#[derive(Clone, Debug, PartialEq)]
9128#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9129pub struct StmtRaise {
9130    pub node_index: crate::AtomicNodeIndex,
9131    pub range: ruff_text_size::TextRange,
9132    pub exc: Option<Box<Expr>>,
9133    pub cause: Option<Box<Expr>>,
9134}
9135
9136/// See also [Try](https://docs.python.org/3/library/ast.html#ast.Try)
9137/// and [TryStar](https://docs.python.org/3/library/ast.html#ast.TryStar)
9138#[derive(Clone, Debug, PartialEq)]
9139#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9140pub struct StmtTry {
9141    pub node_index: crate::AtomicNodeIndex,
9142    pub range: ruff_text_size::TextRange,
9143    pub body: Vec<Stmt>,
9144    pub handlers: Vec<ExceptHandler>,
9145    pub orelse: Vec<Stmt>,
9146    pub finalbody: Vec<Stmt>,
9147    pub is_star: bool,
9148}
9149
9150/// See also [Assert](https://docs.python.org/3/library/ast.html#ast.Assert)
9151#[derive(Clone, Debug, PartialEq)]
9152#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9153pub struct StmtAssert {
9154    pub node_index: crate::AtomicNodeIndex,
9155    pub range: ruff_text_size::TextRange,
9156    pub test: Box<Expr>,
9157    pub msg: Option<Box<Expr>>,
9158}
9159
9160/// See also [Import](https://docs.python.org/3/library/ast.html#ast.Import)
9161#[derive(Clone, Debug, PartialEq)]
9162#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9163pub struct StmtImport {
9164    pub node_index: crate::AtomicNodeIndex,
9165    pub range: ruff_text_size::TextRange,
9166    pub names: Vec<crate::Alias>,
9167    pub is_lazy: bool,
9168}
9169
9170/// See also [ImportFrom](https://docs.python.org/3/library/ast.html#ast.ImportFrom)
9171#[derive(Clone, Debug, PartialEq)]
9172#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9173pub struct StmtImportFrom {
9174    pub node_index: crate::AtomicNodeIndex,
9175    pub range: ruff_text_size::TextRange,
9176    pub module: Option<crate::Identifier>,
9177    pub names: Vec<crate::Alias>,
9178    pub level: u32,
9179    pub is_lazy: bool,
9180}
9181
9182/// See also [Global](https://docs.python.org/3/library/ast.html#ast.Global)
9183#[derive(Clone, Debug, PartialEq)]
9184#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9185pub struct StmtGlobal {
9186    pub node_index: crate::AtomicNodeIndex,
9187    pub range: ruff_text_size::TextRange,
9188    pub names: Vec<crate::Identifier>,
9189}
9190
9191/// See also [Nonlocal](https://docs.python.org/3/library/ast.html#ast.Nonlocal)
9192#[derive(Clone, Debug, PartialEq)]
9193#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9194pub struct StmtNonlocal {
9195    pub node_index: crate::AtomicNodeIndex,
9196    pub range: ruff_text_size::TextRange,
9197    pub names: Vec<crate::Identifier>,
9198}
9199
9200/// See also [Expr](https://docs.python.org/3/library/ast.html#ast.Expr)
9201#[derive(Clone, Debug, PartialEq)]
9202#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9203pub struct StmtExpr {
9204    pub node_index: crate::AtomicNodeIndex,
9205    pub range: ruff_text_size::TextRange,
9206    pub value: Box<Expr>,
9207}
9208
9209/// See also [Pass](https://docs.python.org/3/library/ast.html#ast.Pass)
9210#[derive(Clone, Debug, PartialEq)]
9211#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9212pub struct StmtPass {
9213    pub node_index: crate::AtomicNodeIndex,
9214    pub range: ruff_text_size::TextRange,
9215}
9216
9217/// See also [Break](https://docs.python.org/3/library/ast.html#ast.Break)
9218#[derive(Clone, Debug, PartialEq)]
9219#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9220pub struct StmtBreak {
9221    pub node_index: crate::AtomicNodeIndex,
9222    pub range: ruff_text_size::TextRange,
9223}
9224
9225/// See also [Continue](https://docs.python.org/3/library/ast.html#ast.Continue)
9226#[derive(Clone, Debug, PartialEq)]
9227#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9228pub struct StmtContinue {
9229    pub node_index: crate::AtomicNodeIndex,
9230    pub range: ruff_text_size::TextRange,
9231}
9232
9233/// An AST node used to represent a IPython escape command at the statement level.
9234///
9235/// For example,
9236/// ```python
9237/// %matplotlib inline
9238/// ```
9239///
9240/// ## Terminology
9241///
9242/// Escape commands are special IPython syntax which starts with a token to identify
9243/// the escape kind followed by the command value itself. [Escape kind] are the kind
9244/// of escape commands that are recognized by the token: `%`, `%%`, `!`, `!!`,
9245/// `?`, `??`, `/`, `;`, and `,`.
9246///
9247/// Help command (or Dynamic Object Introspection as it's called) are the escape commands
9248/// of the kind `?` and `??`. For example, `?str.replace`. Help end command are a subset
9249/// of Help command where the token can be at the end of the line i.e., after the value.
9250/// For example, `str.replace?`.
9251///
9252/// Here's where things get tricky. I'll divide the help end command into two types for
9253/// better understanding:
9254/// 1. Strict version: The token is _only_ at the end of the line. For example,
9255///    `str.replace?` or `str.replace??`.
9256/// 2. Combined version: Along with the `?` or `??` token, which are at the end of the
9257///    line, there are other escape kind tokens that are present at the start as well.
9258///    For example, `%matplotlib?` or `%%timeit?`.
9259///
9260/// Priority comes into picture for the "Combined version" mentioned above. How do
9261/// we determine the escape kind if there are tokens on both side of the value, i.e., which
9262/// token to choose? The Help end command always takes priority over any other token which
9263/// means that if there is `?`/`??` at the end then that is used to determine the kind.
9264/// For example, in `%matplotlib?` the escape kind is determined using the `?` token
9265/// instead of `%` token.
9266///
9267/// ## Syntax
9268///
9269/// `<IpyEscapeKind><Command value>`
9270///
9271/// The simplest form is an escape kind token followed by the command value. For example,
9272/// `%matplotlib inline`, `/foo`, `!pwd`, etc.
9273///
9274/// `<Command value><IpyEscapeKind ("?" or "??")>`
9275///
9276/// The help end escape command would be the reverse of the above syntax. Here, the
9277/// escape kind token can only be either `?` or `??` and it is at the end of the line.
9278/// For example, `str.replace?`, `math.pi??`, etc.
9279///
9280/// `<IpyEscapeKind><Command value><EscapeKind ("?" or "??")>`
9281///
9282/// The final syntax is the combined version of the above two. For example, `%matplotlib?`,
9283/// `%%timeit??`, etc.
9284///
9285/// [Escape kind]: crate::IpyEscapeKind
9286///
9287#[derive(Clone, Debug, PartialEq)]
9288#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9289pub struct StmtIpyEscapeCommand {
9290    pub node_index: crate::AtomicNodeIndex,
9291    pub range: ruff_text_size::TextRange,
9292    pub kind: crate::IpyEscapeKind,
9293    pub value: Box<str>,
9294}
9295
9296/// See also [BoolOp](https://docs.python.org/3/library/ast.html#ast.BoolOp)
9297#[derive(Clone, Debug, PartialEq)]
9298#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9299pub struct ExprBoolOp {
9300    pub node_index: crate::AtomicNodeIndex,
9301    pub range: ruff_text_size::TextRange,
9302    pub op: crate::BoolOp,
9303    pub values: Vec<Expr>,
9304}
9305
9306/// See also [NamedExpr](https://docs.python.org/3/library/ast.html#ast.NamedExpr)
9307#[derive(Clone, Debug, PartialEq)]
9308#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9309pub struct ExprNamed {
9310    pub node_index: crate::AtomicNodeIndex,
9311    pub range: ruff_text_size::TextRange,
9312    pub target: Box<Expr>,
9313    pub value: Box<Expr>,
9314}
9315
9316/// See also [BinOp](https://docs.python.org/3/library/ast.html#ast.BinOp)
9317#[derive(Clone, Debug, PartialEq)]
9318#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9319pub struct ExprBinOp {
9320    pub node_index: crate::AtomicNodeIndex,
9321    pub range: ruff_text_size::TextRange,
9322    pub left: Box<Expr>,
9323    pub op: crate::Operator,
9324    pub right: Box<Expr>,
9325}
9326
9327/// See also [UnaryOp](https://docs.python.org/3/library/ast.html#ast.UnaryOp)
9328#[derive(Clone, Debug, PartialEq)]
9329#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9330pub struct ExprUnaryOp {
9331    pub node_index: crate::AtomicNodeIndex,
9332    pub range: ruff_text_size::TextRange,
9333    pub op: crate::UnaryOp,
9334    pub operand: Box<Expr>,
9335}
9336
9337/// See also [Lambda](https://docs.python.org/3/library/ast.html#ast.Lambda)
9338#[derive(Clone, Debug, PartialEq)]
9339#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9340pub struct ExprLambda {
9341    pub node_index: crate::AtomicNodeIndex,
9342    pub range: ruff_text_size::TextRange,
9343    pub parameters: Option<Box<crate::Parameters>>,
9344    pub body: Box<Expr>,
9345}
9346
9347/// See also [IfExp](https://docs.python.org/3/library/ast.html#ast.IfExp)
9348#[derive(Clone, Debug, PartialEq)]
9349#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9350pub struct ExprIf {
9351    pub node_index: crate::AtomicNodeIndex,
9352    pub range: ruff_text_size::TextRange,
9353    pub test: Box<Expr>,
9354    pub body: Box<Expr>,
9355    pub orelse: Box<Expr>,
9356}
9357
9358/// See also [Dict](https://docs.python.org/3/library/ast.html#ast.Dict)
9359#[derive(Clone, Debug, PartialEq)]
9360#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9361pub struct ExprDict {
9362    pub node_index: crate::AtomicNodeIndex,
9363    pub range: ruff_text_size::TextRange,
9364    pub items: Vec<crate::DictItem>,
9365}
9366
9367/// See also [Set](https://docs.python.org/3/library/ast.html#ast.Set)
9368#[derive(Clone, Debug, PartialEq)]
9369#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9370pub struct ExprSet {
9371    pub node_index: crate::AtomicNodeIndex,
9372    pub range: ruff_text_size::TextRange,
9373    pub elts: Vec<Expr>,
9374}
9375
9376/// See also [ListComp](https://docs.python.org/3/library/ast.html#ast.ListComp)
9377#[derive(Clone, Debug, PartialEq)]
9378#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9379pub struct ExprListComp {
9380    pub node_index: crate::AtomicNodeIndex,
9381    pub range: ruff_text_size::TextRange,
9382    pub elt: Box<Expr>,
9383    pub generators: Vec<crate::Comprehension>,
9384}
9385
9386/// See also [SetComp](https://docs.python.org/3/library/ast.html#ast.SetComp)
9387#[derive(Clone, Debug, PartialEq)]
9388#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9389pub struct ExprSetComp {
9390    pub node_index: crate::AtomicNodeIndex,
9391    pub range: ruff_text_size::TextRange,
9392    pub elt: Box<Expr>,
9393    pub generators: Vec<crate::Comprehension>,
9394}
9395
9396/// See also [DictComp](https://docs.python.org/3/library/ast.html#ast.DictComp)
9397#[derive(Clone, Debug, PartialEq)]
9398#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9399pub struct ExprDictComp {
9400    pub node_index: crate::AtomicNodeIndex,
9401    pub range: ruff_text_size::TextRange,
9402    pub key: Box<Expr>,
9403    pub value: Box<Expr>,
9404    pub generators: Vec<crate::Comprehension>,
9405}
9406
9407/// See also [GeneratorExp](https://docs.python.org/3/library/ast.html#ast.GeneratorExp)
9408#[derive(Clone, Debug, PartialEq)]
9409#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9410pub struct ExprGenerator {
9411    pub node_index: crate::AtomicNodeIndex,
9412    pub range: ruff_text_size::TextRange,
9413    pub elt: Box<Expr>,
9414    pub generators: Vec<crate::Comprehension>,
9415    pub parenthesized: bool,
9416}
9417
9418/// See also [Await](https://docs.python.org/3/library/ast.html#ast.Await)
9419#[derive(Clone, Debug, PartialEq)]
9420#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9421pub struct ExprAwait {
9422    pub node_index: crate::AtomicNodeIndex,
9423    pub range: ruff_text_size::TextRange,
9424    pub value: Box<Expr>,
9425}
9426
9427/// See also [Yield](https://docs.python.org/3/library/ast.html#ast.Yield)
9428#[derive(Clone, Debug, PartialEq)]
9429#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9430pub struct ExprYield {
9431    pub node_index: crate::AtomicNodeIndex,
9432    pub range: ruff_text_size::TextRange,
9433    pub value: Option<Box<Expr>>,
9434}
9435
9436/// See also [YieldFrom](https://docs.python.org/3/library/ast.html#ast.YieldFrom)
9437#[derive(Clone, Debug, PartialEq)]
9438#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9439pub struct ExprYieldFrom {
9440    pub node_index: crate::AtomicNodeIndex,
9441    pub range: ruff_text_size::TextRange,
9442    pub value: Box<Expr>,
9443}
9444
9445/// See also [Compare](https://docs.python.org/3/library/ast.html#ast.Compare)
9446#[derive(Clone, Debug, PartialEq)]
9447#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9448pub struct ExprCompare {
9449    pub node_index: crate::AtomicNodeIndex,
9450    pub range: ruff_text_size::TextRange,
9451    pub left: Box<Expr>,
9452    pub ops: Box<[crate::CmpOp]>,
9453    pub comparators: Box<[Expr]>,
9454}
9455
9456/// See also [Call](https://docs.python.org/3/library/ast.html#ast.Call)
9457#[derive(Clone, Debug, PartialEq)]
9458#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9459pub struct ExprCall {
9460    pub node_index: crate::AtomicNodeIndex,
9461    pub range: ruff_text_size::TextRange,
9462    pub func: Box<Expr>,
9463    pub arguments: crate::Arguments,
9464}
9465
9466/// An AST node that represents either a single-part f-string literal
9467/// or an implicitly concatenated f-string literal.
9468///
9469/// This type differs from the original Python AST `JoinedStr` in that it
9470/// doesn't join the implicitly concatenated parts into a single string. Instead,
9471/// it keeps them separate and provide various methods to access the parts.
9472///
9473/// See also [JoinedStr](https://docs.python.org/3/library/ast.html#ast.JoinedStr)
9474#[derive(Clone, Debug, PartialEq)]
9475#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9476pub struct ExprFString {
9477    pub node_index: crate::AtomicNodeIndex,
9478    pub range: ruff_text_size::TextRange,
9479    pub value: crate::FStringValue,
9480}
9481
9482/// An AST node that represents either a single-part t-string literal
9483/// or an implicitly concatenated t-string literal.
9484///
9485/// This type differs from the original Python AST `TemplateStr` in that it
9486/// doesn't join the implicitly concatenated parts into a single string. Instead,
9487/// it keeps them separate and provide various methods to access the parts.
9488///
9489/// See also [TemplateStr](https://docs.python.org/3/library/ast.html#ast.TemplateStr)
9490#[derive(Clone, Debug, PartialEq)]
9491#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9492pub struct ExprTString {
9493    pub node_index: crate::AtomicNodeIndex,
9494    pub range: ruff_text_size::TextRange,
9495    pub value: crate::TStringValue,
9496}
9497
9498/// An AST node that represents either a single-part string literal
9499/// or an implicitly concatenated string literal.
9500#[derive(Clone, Debug, PartialEq)]
9501#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9502pub struct ExprStringLiteral {
9503    pub node_index: crate::AtomicNodeIndex,
9504    pub range: ruff_text_size::TextRange,
9505    pub value: crate::StringLiteralValue,
9506}
9507
9508/// An AST node that represents either a single-part bytestring literal
9509/// or an implicitly concatenated bytestring literal.
9510#[derive(Clone, Debug, PartialEq)]
9511#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9512pub struct ExprBytesLiteral {
9513    pub node_index: crate::AtomicNodeIndex,
9514    pub range: ruff_text_size::TextRange,
9515    pub value: crate::BytesLiteralValue,
9516}
9517
9518#[derive(Clone, Debug, PartialEq)]
9519#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9520pub struct ExprNumberLiteral {
9521    pub node_index: crate::AtomicNodeIndex,
9522    pub range: ruff_text_size::TextRange,
9523    pub value: crate::Number,
9524}
9525
9526#[derive(Clone, Debug, PartialEq, Default)]
9527#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9528pub struct ExprBooleanLiteral {
9529    pub node_index: crate::AtomicNodeIndex,
9530    pub range: ruff_text_size::TextRange,
9531    pub value: bool,
9532}
9533
9534#[derive(Clone, Debug, PartialEq, Default)]
9535#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9536pub struct ExprNoneLiteral {
9537    pub node_index: crate::AtomicNodeIndex,
9538    pub range: ruff_text_size::TextRange,
9539}
9540
9541#[derive(Clone, Debug, PartialEq, Default)]
9542#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9543pub struct ExprEllipsisLiteral {
9544    pub node_index: crate::AtomicNodeIndex,
9545    pub range: ruff_text_size::TextRange,
9546}
9547
9548/// See also [Attribute](https://docs.python.org/3/library/ast.html#ast.Attribute)
9549#[derive(Clone, Debug, PartialEq)]
9550#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9551pub struct ExprAttribute {
9552    pub node_index: crate::AtomicNodeIndex,
9553    pub range: ruff_text_size::TextRange,
9554    pub value: Box<Expr>,
9555    pub attr: crate::Identifier,
9556    pub ctx: crate::ExprContext,
9557}
9558
9559/// See also [Subscript](https://docs.python.org/3/library/ast.html#ast.Subscript)
9560#[derive(Clone, Debug, PartialEq)]
9561#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9562pub struct ExprSubscript {
9563    pub node_index: crate::AtomicNodeIndex,
9564    pub range: ruff_text_size::TextRange,
9565    pub value: Box<Expr>,
9566    pub slice: Box<Expr>,
9567    pub ctx: crate::ExprContext,
9568}
9569
9570/// See also [Starred](https://docs.python.org/3/library/ast.html#ast.Starred)
9571#[derive(Clone, Debug, PartialEq)]
9572#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9573pub struct ExprStarred {
9574    pub node_index: crate::AtomicNodeIndex,
9575    pub range: ruff_text_size::TextRange,
9576    pub value: Box<Expr>,
9577    pub ctx: crate::ExprContext,
9578}
9579
9580/// See also [Name](https://docs.python.org/3/library/ast.html#ast.Name)
9581#[derive(Clone, Debug, PartialEq)]
9582#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9583pub struct ExprName {
9584    pub node_index: crate::AtomicNodeIndex,
9585    pub range: ruff_text_size::TextRange,
9586    pub id: Name,
9587    pub ctx: crate::ExprContext,
9588}
9589
9590/// See also [List](https://docs.python.org/3/library/ast.html#ast.List)
9591#[derive(Clone, Debug, PartialEq)]
9592#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9593pub struct ExprList {
9594    pub node_index: crate::AtomicNodeIndex,
9595    pub range: ruff_text_size::TextRange,
9596    pub elts: Vec<Expr>,
9597    pub ctx: crate::ExprContext,
9598}
9599
9600/// See also [Tuple](https://docs.python.org/3/library/ast.html#ast.Tuple)
9601#[derive(Clone, Debug, PartialEq)]
9602#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9603pub struct ExprTuple {
9604    pub node_index: crate::AtomicNodeIndex,
9605    pub range: ruff_text_size::TextRange,
9606    pub elts: Vec<Expr>,
9607    pub ctx: crate::ExprContext,
9608    pub parenthesized: bool,
9609}
9610
9611/// See also [Slice](https://docs.python.org/3/library/ast.html#ast.Slice)
9612#[derive(Clone, Debug, PartialEq)]
9613#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9614pub struct ExprSlice {
9615    pub node_index: crate::AtomicNodeIndex,
9616    pub range: ruff_text_size::TextRange,
9617    pub lower: Option<Box<Expr>>,
9618    pub upper: Option<Box<Expr>>,
9619    pub step: Option<Box<Expr>>,
9620}
9621
9622/// An AST node used to represent a IPython escape command at the expression level.
9623///
9624/// For example,
9625/// ```python
9626/// dir = !pwd
9627/// ```
9628///
9629/// Here, the escape kind can only be `!` or `%` otherwise it is a syntax error.
9630///
9631/// For more information related to terminology and syntax of escape commands,
9632/// see [`StmtIpyEscapeCommand`].
9633#[derive(Clone, Debug, PartialEq)]
9634#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9635pub struct ExprIpyEscapeCommand {
9636    pub node_index: crate::AtomicNodeIndex,
9637    pub range: ruff_text_size::TextRange,
9638    pub kind: crate::IpyEscapeKind,
9639    pub value: Box<str>,
9640}
9641
9642/// See also [MatchValue](https://docs.python.org/3/library/ast.html#ast.MatchValue)
9643#[derive(Clone, Debug, PartialEq)]
9644#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9645pub struct PatternMatchValue {
9646    pub node_index: crate::AtomicNodeIndex,
9647    pub range: ruff_text_size::TextRange,
9648    pub value: Box<Expr>,
9649}
9650
9651/// See also [MatchSingleton](https://docs.python.org/3/library/ast.html#ast.MatchSingleton)
9652#[derive(Clone, Debug, PartialEq)]
9653#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9654pub struct PatternMatchSingleton {
9655    pub node_index: crate::AtomicNodeIndex,
9656    pub range: ruff_text_size::TextRange,
9657    pub value: crate::Singleton,
9658}
9659
9660/// See also [MatchSequence](https://docs.python.org/3/library/ast.html#ast.MatchSequence)
9661#[derive(Clone, Debug, PartialEq)]
9662#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9663pub struct PatternMatchSequence {
9664    pub node_index: crate::AtomicNodeIndex,
9665    pub range: ruff_text_size::TextRange,
9666    pub patterns: Vec<Pattern>,
9667}
9668
9669/// See also [MatchMapping](https://docs.python.org/3/library/ast.html#ast.MatchMapping)
9670#[derive(Clone, Debug, PartialEq)]
9671#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9672pub struct PatternMatchMapping {
9673    pub node_index: crate::AtomicNodeIndex,
9674    pub range: ruff_text_size::TextRange,
9675    pub keys: Vec<Expr>,
9676    pub patterns: Vec<Pattern>,
9677    pub rest: Option<crate::Identifier>,
9678}
9679
9680/// See also [MatchClass](https://docs.python.org/3/library/ast.html#ast.MatchClass)
9681#[derive(Clone, Debug, PartialEq)]
9682#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9683pub struct PatternMatchClass {
9684    pub node_index: crate::AtomicNodeIndex,
9685    pub range: ruff_text_size::TextRange,
9686    pub cls: Box<Expr>,
9687    pub arguments: crate::PatternArguments,
9688}
9689
9690/// See also [MatchStar](https://docs.python.org/3/library/ast.html#ast.MatchStar)
9691#[derive(Clone, Debug, PartialEq)]
9692#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9693pub struct PatternMatchStar {
9694    pub node_index: crate::AtomicNodeIndex,
9695    pub range: ruff_text_size::TextRange,
9696    pub name: Option<crate::Identifier>,
9697}
9698
9699/// See also [MatchAs](https://docs.python.org/3/library/ast.html#ast.MatchAs)
9700#[derive(Clone, Debug, PartialEq)]
9701#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9702pub struct PatternMatchAs {
9703    pub node_index: crate::AtomicNodeIndex,
9704    pub range: ruff_text_size::TextRange,
9705    pub pattern: Option<Box<Pattern>>,
9706    pub name: Option<crate::Identifier>,
9707}
9708
9709/// See also [MatchOr](https://docs.python.org/3/library/ast.html#ast.MatchOr)
9710#[derive(Clone, Debug, PartialEq)]
9711#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9712pub struct PatternMatchOr {
9713    pub node_index: crate::AtomicNodeIndex,
9714    pub range: ruff_text_size::TextRange,
9715    pub patterns: Vec<Pattern>,
9716}
9717
9718/// See also [TypeVar](https://docs.python.org/3/library/ast.html#ast.TypeVar)
9719#[derive(Clone, Debug, PartialEq)]
9720#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9721pub struct TypeParamTypeVar {
9722    pub node_index: crate::AtomicNodeIndex,
9723    pub range: ruff_text_size::TextRange,
9724    pub name: crate::Identifier,
9725    pub bound: Option<Box<Expr>>,
9726    pub default: Option<Box<Expr>>,
9727}
9728
9729/// See also [TypeVarTuple](https://docs.python.org/3/library/ast.html#ast.TypeVarTuple)
9730#[derive(Clone, Debug, PartialEq)]
9731#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9732pub struct TypeParamTypeVarTuple {
9733    pub node_index: crate::AtomicNodeIndex,
9734    pub range: ruff_text_size::TextRange,
9735    pub name: crate::Identifier,
9736    pub default: Option<Box<Expr>>,
9737}
9738
9739/// See also [ParamSpec](https://docs.python.org/3/library/ast.html#ast.ParamSpec)
9740#[derive(Clone, Debug, PartialEq)]
9741#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
9742pub struct TypeParamParamSpec {
9743    pub node_index: crate::AtomicNodeIndex,
9744    pub range: ruff_text_size::TextRange,
9745    pub name: crate::Identifier,
9746    pub default: Option<Box<Expr>>,
9747}
9748
9749impl ModModule {
9750    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
9751    where
9752        V: SourceOrderVisitor<'a> + ?Sized,
9753    {
9754        let ModModule {
9755            body,
9756            range: _,
9757            node_index: _,
9758        } = self;
9759        visitor.visit_body(body);
9760    }
9761}
9762
9763impl ModExpression {
9764    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
9765    where
9766        V: SourceOrderVisitor<'a> + ?Sized,
9767    {
9768        let ModExpression {
9769            body,
9770            range: _,
9771            node_index: _,
9772        } = self;
9773        visitor.visit_expr(body);
9774    }
9775}
9776
9777impl StmtFunctionDef {
9778    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
9779    where
9780        V: SourceOrderVisitor<'a> + ?Sized,
9781    {
9782        let StmtFunctionDef {
9783            is_async: _,
9784            decorator_list,
9785            name,
9786            type_params,
9787            parameters,
9788            returns,
9789            body,
9790            range: _,
9791            node_index: _,
9792        } = self;
9793
9794        for elm in decorator_list {
9795            visitor.visit_decorator(elm);
9796        }
9797        visitor.visit_identifier(name);
9798
9799        if let Some(type_params) = type_params {
9800            visitor.visit_type_params(type_params);
9801        }
9802
9803        visitor.visit_parameters(parameters);
9804
9805        if let Some(returns) = returns {
9806            visitor.visit_annotation(returns);
9807        }
9808
9809        visitor.visit_body(body);
9810    }
9811}
9812
9813impl StmtClassDef {
9814    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
9815    where
9816        V: SourceOrderVisitor<'a> + ?Sized,
9817    {
9818        let StmtClassDef {
9819            decorator_list,
9820            name,
9821            type_params,
9822            arguments,
9823            body,
9824            range: _,
9825            node_index: _,
9826        } = self;
9827
9828        for elm in decorator_list {
9829            visitor.visit_decorator(elm);
9830        }
9831        visitor.visit_identifier(name);
9832
9833        if let Some(type_params) = type_params {
9834            visitor.visit_type_params(type_params);
9835        }
9836
9837        if let Some(arguments) = arguments {
9838            visitor.visit_arguments(arguments);
9839        }
9840
9841        visitor.visit_body(body);
9842    }
9843}
9844
9845impl StmtReturn {
9846    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
9847    where
9848        V: SourceOrderVisitor<'a> + ?Sized,
9849    {
9850        let StmtReturn {
9851            value,
9852            range: _,
9853            node_index: _,
9854        } = self;
9855
9856        if let Some(value) = value {
9857            visitor.visit_expr(value);
9858        }
9859    }
9860}
9861
9862impl StmtDelete {
9863    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
9864    where
9865        V: SourceOrderVisitor<'a> + ?Sized,
9866    {
9867        let StmtDelete {
9868            targets,
9869            range: _,
9870            node_index: _,
9871        } = self;
9872
9873        for elm in targets {
9874            visitor.visit_expr(elm);
9875        }
9876    }
9877}
9878
9879impl StmtTypeAlias {
9880    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
9881    where
9882        V: SourceOrderVisitor<'a> + ?Sized,
9883    {
9884        let StmtTypeAlias {
9885            name,
9886            type_params,
9887            value,
9888            range: _,
9889            node_index: _,
9890        } = self;
9891        visitor.visit_expr(name);
9892
9893        if let Some(type_params) = type_params {
9894            visitor.visit_type_params(type_params);
9895        }
9896
9897        visitor.visit_expr(value);
9898    }
9899}
9900
9901impl StmtAssign {
9902    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
9903    where
9904        V: SourceOrderVisitor<'a> + ?Sized,
9905    {
9906        let StmtAssign {
9907            targets,
9908            value,
9909            range: _,
9910            node_index: _,
9911        } = self;
9912
9913        for elm in targets {
9914            visitor.visit_expr(elm);
9915        }
9916        visitor.visit_expr(value);
9917    }
9918}
9919
9920impl StmtAugAssign {
9921    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
9922    where
9923        V: SourceOrderVisitor<'a> + ?Sized,
9924    {
9925        let StmtAugAssign {
9926            target,
9927            op,
9928            value,
9929            range: _,
9930            node_index: _,
9931        } = self;
9932        visitor.visit_expr(target);
9933        visitor.visit_operator(op);
9934        visitor.visit_expr(value);
9935    }
9936}
9937
9938impl StmtAnnAssign {
9939    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
9940    where
9941        V: SourceOrderVisitor<'a> + ?Sized,
9942    {
9943        let StmtAnnAssign {
9944            target,
9945            annotation,
9946            value,
9947            simple: _,
9948            range: _,
9949            node_index: _,
9950        } = self;
9951        visitor.visit_expr(target);
9952        visitor.visit_annotation(annotation);
9953
9954        if let Some(value) = value {
9955            visitor.visit_expr(value);
9956        }
9957    }
9958}
9959
9960impl StmtFor {
9961    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
9962    where
9963        V: SourceOrderVisitor<'a> + ?Sized,
9964    {
9965        let StmtFor {
9966            is_async: _,
9967            target,
9968            iter,
9969            body,
9970            orelse,
9971            range: _,
9972            node_index: _,
9973        } = self;
9974        visitor.visit_expr(target);
9975        visitor.visit_expr(iter);
9976        visitor.visit_body(body);
9977        visitor.visit_body(orelse);
9978    }
9979}
9980
9981impl StmtWhile {
9982    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
9983    where
9984        V: SourceOrderVisitor<'a> + ?Sized,
9985    {
9986        let StmtWhile {
9987            test,
9988            body,
9989            orelse,
9990            range: _,
9991            node_index: _,
9992        } = self;
9993        visitor.visit_expr(test);
9994        visitor.visit_body(body);
9995        visitor.visit_body(orelse);
9996    }
9997}
9998
9999impl StmtIf {
10000    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10001    where
10002        V: SourceOrderVisitor<'a> + ?Sized,
10003    {
10004        let StmtIf {
10005            test,
10006            body,
10007            elif_else_clauses,
10008            range: _,
10009            node_index: _,
10010        } = self;
10011        visitor.visit_expr(test);
10012        visitor.visit_body(body);
10013
10014        for elm in elif_else_clauses {
10015            visitor.visit_elif_else_clause(elm);
10016        }
10017    }
10018}
10019
10020impl StmtWith {
10021    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10022    where
10023        V: SourceOrderVisitor<'a> + ?Sized,
10024    {
10025        let StmtWith {
10026            is_async: _,
10027            items,
10028            body,
10029            range: _,
10030            node_index: _,
10031        } = self;
10032
10033        for elm in items {
10034            visitor.visit_with_item(elm);
10035        }
10036        visitor.visit_body(body);
10037    }
10038}
10039
10040impl StmtMatch {
10041    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10042    where
10043        V: SourceOrderVisitor<'a> + ?Sized,
10044    {
10045        let StmtMatch {
10046            subject,
10047            cases,
10048            range: _,
10049            node_index: _,
10050        } = self;
10051        visitor.visit_expr(subject);
10052
10053        for elm in cases {
10054            visitor.visit_match_case(elm);
10055        }
10056    }
10057}
10058
10059impl StmtRaise {
10060    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10061    where
10062        V: SourceOrderVisitor<'a> + ?Sized,
10063    {
10064        let StmtRaise {
10065            exc,
10066            cause,
10067            range: _,
10068            node_index: _,
10069        } = self;
10070
10071        if let Some(exc) = exc {
10072            visitor.visit_expr(exc);
10073        }
10074
10075        if let Some(cause) = cause {
10076            visitor.visit_expr(cause);
10077        }
10078    }
10079}
10080
10081impl StmtTry {
10082    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10083    where
10084        V: SourceOrderVisitor<'a> + ?Sized,
10085    {
10086        let StmtTry {
10087            body,
10088            handlers,
10089            orelse,
10090            finalbody,
10091            is_star: _,
10092            range: _,
10093            node_index: _,
10094        } = self;
10095        visitor.visit_body(body);
10096
10097        for elm in handlers {
10098            visitor.visit_except_handler(elm);
10099        }
10100        visitor.visit_body(orelse);
10101        visitor.visit_body(finalbody);
10102    }
10103}
10104
10105impl StmtAssert {
10106    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10107    where
10108        V: SourceOrderVisitor<'a> + ?Sized,
10109    {
10110        let StmtAssert {
10111            test,
10112            msg,
10113            range: _,
10114            node_index: _,
10115        } = self;
10116        visitor.visit_expr(test);
10117
10118        if let Some(msg) = msg {
10119            visitor.visit_expr(msg);
10120        }
10121    }
10122}
10123
10124impl StmtImport {
10125    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10126    where
10127        V: SourceOrderVisitor<'a> + ?Sized,
10128    {
10129        let StmtImport {
10130            names,
10131            is_lazy: _,
10132            range: _,
10133            node_index: _,
10134        } = self;
10135
10136        for elm in names {
10137            visitor.visit_alias(elm);
10138        }
10139    }
10140}
10141
10142impl StmtImportFrom {
10143    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10144    where
10145        V: SourceOrderVisitor<'a> + ?Sized,
10146    {
10147        let StmtImportFrom {
10148            module,
10149            names,
10150            level: _,
10151            is_lazy: _,
10152            range: _,
10153            node_index: _,
10154        } = self;
10155
10156        if let Some(module) = module {
10157            visitor.visit_identifier(module);
10158        }
10159
10160        for elm in names {
10161            visitor.visit_alias(elm);
10162        }
10163    }
10164}
10165
10166impl StmtGlobal {
10167    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10168    where
10169        V: SourceOrderVisitor<'a> + ?Sized,
10170    {
10171        let StmtGlobal {
10172            names,
10173            range: _,
10174            node_index: _,
10175        } = self;
10176
10177        for elm in names {
10178            visitor.visit_identifier(elm);
10179        }
10180    }
10181}
10182
10183impl StmtNonlocal {
10184    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10185    where
10186        V: SourceOrderVisitor<'a> + ?Sized,
10187    {
10188        let StmtNonlocal {
10189            names,
10190            range: _,
10191            node_index: _,
10192        } = self;
10193
10194        for elm in names {
10195            visitor.visit_identifier(elm);
10196        }
10197    }
10198}
10199
10200impl StmtExpr {
10201    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10202    where
10203        V: SourceOrderVisitor<'a> + ?Sized,
10204    {
10205        let StmtExpr {
10206            value,
10207            range: _,
10208            node_index: _,
10209        } = self;
10210        visitor.visit_expr(value);
10211    }
10212}
10213
10214impl StmtPass {
10215    pub(crate) fn visit_source_order<'a, V>(&'a self, _: &mut V)
10216    where
10217        V: SourceOrderVisitor<'a> + ?Sized,
10218    {
10219        let StmtPass {
10220            range: _,
10221            node_index: _,
10222        } = self;
10223    }
10224}
10225
10226impl StmtBreak {
10227    pub(crate) fn visit_source_order<'a, V>(&'a self, _: &mut V)
10228    where
10229        V: SourceOrderVisitor<'a> + ?Sized,
10230    {
10231        let StmtBreak {
10232            range: _,
10233            node_index: _,
10234        } = self;
10235    }
10236}
10237
10238impl StmtContinue {
10239    pub(crate) fn visit_source_order<'a, V>(&'a self, _: &mut V)
10240    where
10241        V: SourceOrderVisitor<'a> + ?Sized,
10242    {
10243        let StmtContinue {
10244            range: _,
10245            node_index: _,
10246        } = self;
10247    }
10248}
10249
10250impl StmtIpyEscapeCommand {
10251    pub(crate) fn visit_source_order<'a, V>(&'a self, _: &mut V)
10252    where
10253        V: SourceOrderVisitor<'a> + ?Sized,
10254    {
10255        let StmtIpyEscapeCommand {
10256            kind: _,
10257            value: _,
10258            range: _,
10259            node_index: _,
10260        } = self;
10261    }
10262}
10263
10264impl ExprNamed {
10265    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10266    where
10267        V: SourceOrderVisitor<'a> + ?Sized,
10268    {
10269        let ExprNamed {
10270            target,
10271            value,
10272            range: _,
10273            node_index: _,
10274        } = self;
10275        visitor.visit_expr(target);
10276        visitor.visit_expr(value);
10277    }
10278}
10279
10280impl ExprBinOp {
10281    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10282    where
10283        V: SourceOrderVisitor<'a> + ?Sized,
10284    {
10285        let ExprBinOp {
10286            left,
10287            op,
10288            right,
10289            range: _,
10290            node_index: _,
10291        } = self;
10292        visitor.visit_expr(left);
10293        visitor.visit_operator(op);
10294        visitor.visit_expr(right);
10295    }
10296}
10297
10298impl ExprUnaryOp {
10299    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10300    where
10301        V: SourceOrderVisitor<'a> + ?Sized,
10302    {
10303        let ExprUnaryOp {
10304            op,
10305            operand,
10306            range: _,
10307            node_index: _,
10308        } = self;
10309        visitor.visit_unary_op(op);
10310        visitor.visit_expr(operand);
10311    }
10312}
10313
10314impl ExprLambda {
10315    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10316    where
10317        V: SourceOrderVisitor<'a> + ?Sized,
10318    {
10319        let ExprLambda {
10320            parameters,
10321            body,
10322            range: _,
10323            node_index: _,
10324        } = self;
10325
10326        if let Some(parameters) = parameters {
10327            visitor.visit_parameters(parameters);
10328        }
10329
10330        visitor.visit_expr(body);
10331    }
10332}
10333
10334impl ExprIf {
10335    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10336    where
10337        V: SourceOrderVisitor<'a> + ?Sized,
10338    {
10339        let ExprIf {
10340            test,
10341            body,
10342            orelse,
10343            range: _,
10344            node_index: _,
10345        } = self;
10346        visitor.visit_expr(body);
10347        visitor.visit_expr(test);
10348        visitor.visit_expr(orelse);
10349    }
10350}
10351
10352impl ExprSet {
10353    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10354    where
10355        V: SourceOrderVisitor<'a> + ?Sized,
10356    {
10357        let ExprSet {
10358            elts,
10359            range: _,
10360            node_index: _,
10361        } = self;
10362
10363        for elm in elts {
10364            visitor.visit_expr(elm);
10365        }
10366    }
10367}
10368
10369impl ExprListComp {
10370    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10371    where
10372        V: SourceOrderVisitor<'a> + ?Sized,
10373    {
10374        let ExprListComp {
10375            elt,
10376            generators,
10377            range: _,
10378            node_index: _,
10379        } = self;
10380        visitor.visit_expr(elt);
10381
10382        for elm in generators {
10383            visitor.visit_comprehension(elm);
10384        }
10385    }
10386}
10387
10388impl ExprSetComp {
10389    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10390    where
10391        V: SourceOrderVisitor<'a> + ?Sized,
10392    {
10393        let ExprSetComp {
10394            elt,
10395            generators,
10396            range: _,
10397            node_index: _,
10398        } = self;
10399        visitor.visit_expr(elt);
10400
10401        for elm in generators {
10402            visitor.visit_comprehension(elm);
10403        }
10404    }
10405}
10406
10407impl ExprDictComp {
10408    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10409    where
10410        V: SourceOrderVisitor<'a> + ?Sized,
10411    {
10412        let ExprDictComp {
10413            key,
10414            value,
10415            generators,
10416            range: _,
10417            node_index: _,
10418        } = self;
10419        visitor.visit_expr(key);
10420        visitor.visit_expr(value);
10421
10422        for elm in generators {
10423            visitor.visit_comprehension(elm);
10424        }
10425    }
10426}
10427
10428impl ExprGenerator {
10429    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10430    where
10431        V: SourceOrderVisitor<'a> + ?Sized,
10432    {
10433        let ExprGenerator {
10434            elt,
10435            generators,
10436            parenthesized: _,
10437            range: _,
10438            node_index: _,
10439        } = self;
10440        visitor.visit_expr(elt);
10441
10442        for elm in generators {
10443            visitor.visit_comprehension(elm);
10444        }
10445    }
10446}
10447
10448impl ExprAwait {
10449    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10450    where
10451        V: SourceOrderVisitor<'a> + ?Sized,
10452    {
10453        let ExprAwait {
10454            value,
10455            range: _,
10456            node_index: _,
10457        } = self;
10458        visitor.visit_expr(value);
10459    }
10460}
10461
10462impl ExprYield {
10463    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10464    where
10465        V: SourceOrderVisitor<'a> + ?Sized,
10466    {
10467        let ExprYield {
10468            value,
10469            range: _,
10470            node_index: _,
10471        } = self;
10472
10473        if let Some(value) = value {
10474            visitor.visit_expr(value);
10475        }
10476    }
10477}
10478
10479impl ExprYieldFrom {
10480    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10481    where
10482        V: SourceOrderVisitor<'a> + ?Sized,
10483    {
10484        let ExprYieldFrom {
10485            value,
10486            range: _,
10487            node_index: _,
10488        } = self;
10489        visitor.visit_expr(value);
10490    }
10491}
10492
10493impl ExprCall {
10494    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10495    where
10496        V: SourceOrderVisitor<'a> + ?Sized,
10497    {
10498        let ExprCall {
10499            func,
10500            arguments,
10501            range: _,
10502            node_index: _,
10503        } = self;
10504        visitor.visit_expr(func);
10505        visitor.visit_arguments(arguments);
10506    }
10507}
10508
10509impl ExprNumberLiteral {
10510    pub(crate) fn visit_source_order<'a, V>(&'a self, _: &mut V)
10511    where
10512        V: SourceOrderVisitor<'a> + ?Sized,
10513    {
10514        let ExprNumberLiteral {
10515            value: _,
10516            range: _,
10517            node_index: _,
10518        } = self;
10519    }
10520}
10521
10522impl ExprBooleanLiteral {
10523    pub(crate) fn visit_source_order<'a, V>(&'a self, _: &mut V)
10524    where
10525        V: SourceOrderVisitor<'a> + ?Sized,
10526    {
10527        let ExprBooleanLiteral {
10528            value: _,
10529            range: _,
10530            node_index: _,
10531        } = self;
10532    }
10533}
10534
10535impl ExprNoneLiteral {
10536    pub(crate) fn visit_source_order<'a, V>(&'a self, _: &mut V)
10537    where
10538        V: SourceOrderVisitor<'a> + ?Sized,
10539    {
10540        let ExprNoneLiteral {
10541            range: _,
10542            node_index: _,
10543        } = self;
10544    }
10545}
10546
10547impl ExprEllipsisLiteral {
10548    pub(crate) fn visit_source_order<'a, V>(&'a self, _: &mut V)
10549    where
10550        V: SourceOrderVisitor<'a> + ?Sized,
10551    {
10552        let ExprEllipsisLiteral {
10553            range: _,
10554            node_index: _,
10555        } = self;
10556    }
10557}
10558
10559impl ExprAttribute {
10560    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10561    where
10562        V: SourceOrderVisitor<'a> + ?Sized,
10563    {
10564        let ExprAttribute {
10565            value,
10566            attr,
10567            ctx: _,
10568            range: _,
10569            node_index: _,
10570        } = self;
10571        visitor.visit_expr(value);
10572        visitor.visit_identifier(attr);
10573    }
10574}
10575
10576impl ExprSubscript {
10577    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10578    where
10579        V: SourceOrderVisitor<'a> + ?Sized,
10580    {
10581        let ExprSubscript {
10582            value,
10583            slice,
10584            ctx: _,
10585            range: _,
10586            node_index: _,
10587        } = self;
10588        visitor.visit_expr(value);
10589        visitor.visit_expr(slice);
10590    }
10591}
10592
10593impl ExprStarred {
10594    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10595    where
10596        V: SourceOrderVisitor<'a> + ?Sized,
10597    {
10598        let ExprStarred {
10599            value,
10600            ctx: _,
10601            range: _,
10602            node_index: _,
10603        } = self;
10604        visitor.visit_expr(value);
10605    }
10606}
10607
10608impl ExprName {
10609    pub(crate) fn visit_source_order<'a, V>(&'a self, _: &mut V)
10610    where
10611        V: SourceOrderVisitor<'a> + ?Sized,
10612    {
10613        let ExprName {
10614            id: _,
10615            ctx: _,
10616            range: _,
10617            node_index: _,
10618        } = self;
10619    }
10620}
10621
10622impl ExprList {
10623    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10624    where
10625        V: SourceOrderVisitor<'a> + ?Sized,
10626    {
10627        let ExprList {
10628            elts,
10629            ctx: _,
10630            range: _,
10631            node_index: _,
10632        } = self;
10633
10634        for elm in elts {
10635            visitor.visit_expr(elm);
10636        }
10637    }
10638}
10639
10640impl ExprTuple {
10641    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10642    where
10643        V: SourceOrderVisitor<'a> + ?Sized,
10644    {
10645        let ExprTuple {
10646            elts,
10647            ctx: _,
10648            parenthesized: _,
10649            range: _,
10650            node_index: _,
10651        } = self;
10652
10653        for elm in elts {
10654            visitor.visit_expr(elm);
10655        }
10656    }
10657}
10658
10659impl ExprSlice {
10660    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10661    where
10662        V: SourceOrderVisitor<'a> + ?Sized,
10663    {
10664        let ExprSlice {
10665            lower,
10666            upper,
10667            step,
10668            range: _,
10669            node_index: _,
10670        } = self;
10671
10672        if let Some(lower) = lower {
10673            visitor.visit_expr(lower);
10674        }
10675
10676        if let Some(upper) = upper {
10677            visitor.visit_expr(upper);
10678        }
10679
10680        if let Some(step) = step {
10681            visitor.visit_expr(step);
10682        }
10683    }
10684}
10685
10686impl ExprIpyEscapeCommand {
10687    pub(crate) fn visit_source_order<'a, V>(&'a self, _: &mut V)
10688    where
10689        V: SourceOrderVisitor<'a> + ?Sized,
10690    {
10691        let ExprIpyEscapeCommand {
10692            kind: _,
10693            value: _,
10694            range: _,
10695            node_index: _,
10696        } = self;
10697    }
10698}
10699
10700impl PatternMatchValue {
10701    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10702    where
10703        V: SourceOrderVisitor<'a> + ?Sized,
10704    {
10705        let PatternMatchValue {
10706            value,
10707            range: _,
10708            node_index: _,
10709        } = self;
10710        visitor.visit_expr(value);
10711    }
10712}
10713
10714impl PatternMatchSingleton {
10715    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10716    where
10717        V: SourceOrderVisitor<'a> + ?Sized,
10718    {
10719        let PatternMatchSingleton {
10720            value,
10721            range: _,
10722            node_index: _,
10723        } = self;
10724        visitor.visit_singleton(value);
10725    }
10726}
10727
10728impl PatternMatchSequence {
10729    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10730    where
10731        V: SourceOrderVisitor<'a> + ?Sized,
10732    {
10733        let PatternMatchSequence {
10734            patterns,
10735            range: _,
10736            node_index: _,
10737        } = self;
10738
10739        for elm in patterns {
10740            visitor.visit_pattern(elm);
10741        }
10742    }
10743}
10744
10745impl PatternMatchClass {
10746    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10747    where
10748        V: SourceOrderVisitor<'a> + ?Sized,
10749    {
10750        let PatternMatchClass {
10751            cls,
10752            arguments,
10753            range: _,
10754            node_index: _,
10755        } = self;
10756        visitor.visit_expr(cls);
10757        visitor.visit_pattern_arguments(arguments);
10758    }
10759}
10760
10761impl PatternMatchStar {
10762    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10763    where
10764        V: SourceOrderVisitor<'a> + ?Sized,
10765    {
10766        let PatternMatchStar {
10767            name,
10768            range: _,
10769            node_index: _,
10770        } = self;
10771
10772        if let Some(name) = name {
10773            visitor.visit_identifier(name);
10774        }
10775    }
10776}
10777
10778impl PatternMatchAs {
10779    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10780    where
10781        V: SourceOrderVisitor<'a> + ?Sized,
10782    {
10783        let PatternMatchAs {
10784            pattern,
10785            name,
10786            range: _,
10787            node_index: _,
10788        } = self;
10789
10790        if let Some(pattern) = pattern {
10791            visitor.visit_pattern(pattern);
10792        }
10793
10794        if let Some(name) = name {
10795            visitor.visit_identifier(name);
10796        }
10797    }
10798}
10799
10800impl PatternMatchOr {
10801    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10802    where
10803        V: SourceOrderVisitor<'a> + ?Sized,
10804    {
10805        let PatternMatchOr {
10806            patterns,
10807            range: _,
10808            node_index: _,
10809        } = self;
10810
10811        for elm in patterns {
10812            visitor.visit_pattern(elm);
10813        }
10814    }
10815}
10816
10817impl TypeParamTypeVar {
10818    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10819    where
10820        V: SourceOrderVisitor<'a> + ?Sized,
10821    {
10822        let TypeParamTypeVar {
10823            name,
10824            bound,
10825            default,
10826            range: _,
10827            node_index: _,
10828        } = self;
10829        visitor.visit_identifier(name);
10830
10831        if let Some(bound) = bound {
10832            visitor.visit_expr(bound);
10833        }
10834
10835        if let Some(default) = default {
10836            visitor.visit_expr(default);
10837        }
10838    }
10839}
10840
10841impl TypeParamTypeVarTuple {
10842    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10843    where
10844        V: SourceOrderVisitor<'a> + ?Sized,
10845    {
10846        let TypeParamTypeVarTuple {
10847            name,
10848            default,
10849            range: _,
10850            node_index: _,
10851        } = self;
10852        visitor.visit_identifier(name);
10853
10854        if let Some(default) = default {
10855            visitor.visit_expr(default);
10856        }
10857    }
10858}
10859
10860impl TypeParamParamSpec {
10861    pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
10862    where
10863        V: SourceOrderVisitor<'a> + ?Sized,
10864    {
10865        let TypeParamParamSpec {
10866            name,
10867            default,
10868            range: _,
10869            node_index: _,
10870        } = self;
10871        visitor.visit_identifier(name);
10872
10873        if let Some(default) = default {
10874            visitor.visit_expr(default);
10875        }
10876    }
10877}