optd_core/rules/ir.rs
1// Copyright (c) 2023-2024 CMU Database Group
2//
3// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at
4// https://opensource.org/licenses/MIT.
5
6use crate::nodes::NodeType;
7
8pub enum RuleMatcher<T: NodeType> {
9 /// Match a node of type `typ`.
10 MatchNode { typ: T, children: Vec<Self> },
11 /// Match "discriminant" (Only check for variant matches---don't consider
12 /// inner data).
13 /// This may be useful when, for example, one has an enum variant such as
14 /// ConstantExpr(ConstantType), and one wants to match on all ConstantExpr
15 /// regardless of the inner ConstantType.
16 MatchDiscriminant {
17 typ_discriminant: std::mem::Discriminant<T>,
18 children: Vec<Self>,
19 },
20 /// Match any plan node.
21 Any,
22 /// Match all plan node.
23 AnyMany,
24}