summaryrefslogtreecommitdiff
path: root/mingling/src/program/setup.rs
blob: e81247e8ef11edf15b58ff00528822ba59b44c40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use crate::{ProgramCollect, program::Program};

mod basic;
pub use basic::*;

pub trait ProgramSetup<C: ProgramCollect> {
    fn setup(&mut self, program: &mut Program<C>);
}

impl<C> Program<C>
where
    C: ProgramCollect,
{
    /// Load and execute init logic
    pub fn with_setup<S: ProgramSetup<C> + 'static>(&mut self, mut setup: S) -> S {
        S::setup(&mut setup, self);
        setup
    }
}