MCPcopy Index your code
hub / github.com/RustPython/RustPython / fold_pattern

Function fold_pattern

crates/vm/src/stdlib/_ast.rs:621–658  ·  view source on GitHub ↗
(pattern: &mut ast::Pattern)

Source from the content-addressed store, hash-verified

619
620#[cfg(feature = "parser")]
621fn fold_pattern(pattern: &mut ast::Pattern) {
622 use ast::Pattern;
623 match pattern {
624 Pattern::MatchValue(value) => fold_expr(&mut value.value),
625 Pattern::MatchSequence(seq) => {
626 for pattern in &mut seq.patterns {
627 fold_pattern(pattern);
628 }
629 }
630 Pattern::MatchMapping(mapping) => {
631 for key in &mut mapping.keys {
632 fold_expr(key);
633 }
634 for pattern in &mut mapping.patterns {
635 fold_pattern(pattern);
636 }
637 }
638 Pattern::MatchClass(class) => {
639 for pattern in &mut class.arguments.patterns {
640 fold_pattern(pattern);
641 }
642 for keyword in &mut class.arguments.keywords {
643 fold_pattern(&mut keyword.pattern);
644 }
645 }
646 Pattern::MatchAs(match_as) => {
647 if let Some(pattern) = match_as.pattern.as_deref_mut() {
648 fold_pattern(pattern);
649 }
650 }
651 Pattern::MatchOr(match_or) => {
652 for pattern in &mut match_or.patterns {
653 fold_pattern(pattern);
654 }
655 }
656 Pattern::MatchSingleton(_) | Pattern::MatchStar(_) => {}
657 }
658}
659
660#[cfg(feature = "parser")]
661fn fold_expr(expr: &mut ast::Expr) {

Callers 1

fold_stmtFunction · 0.85

Calls 1

fold_exprFunction · 0.85

Tested by

no test coverage detected