sqruff_lib_core/parser/segments/
generator.rs

1use crate::dialects::Dialect;
2use crate::parser::matchable::Matchable;
3
4type Generator = fn(&Dialect) -> Matchable;
5
6#[derive(Debug, Clone)]
7pub struct SegmentGenerator {
8    func: Generator,
9}
10
11impl SegmentGenerator {
12    // Define a new function to create a new SegmentGenerator
13    pub fn new(func: Generator) -> SegmentGenerator {
14        SegmentGenerator { func }
15    }
16
17    // Implement the expand function
18    pub fn expand(&self, dialect: &Dialect) -> Matchable {
19        (self.func)(dialect)
20    }
21}