1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use std::sync::Arc;

use crate::core::dialects::base::Dialect;
use crate::core::parser::matchable::Matchable;

type Generator = fn(&Dialect) -> Arc<dyn Matchable>;

#[derive(Debug, Clone)]
pub struct SegmentGenerator {
    func: Generator,
}

impl SegmentGenerator {
    // Define a new function to create a new SegmentGenerator
    pub fn new(func: Generator) -> SegmentGenerator {
        SegmentGenerator { func }
    }

    // Implement the expand function
    pub fn expand(&self, dialect: &Dialect) -> Arc<dyn Matchable> {
        (self.func)(dialect)
    }
}