blob: bf610ca304b6fc5c9aece4d45b00fb4070e291eb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
//! Example Setup
//!
//! > This example demonstrates how to build a custom Setup for modular management of project components
use mingling::{Program, macros::program_setup, prelude::*};
fn main() {
let mut program = ThisProgram::new();
// --------- IMPORTANT ---------
// Introduce `CustomSetup` generated by `custom_setup`
program.with_setup(CustomSetup);
// --------- IMPORTANT ---------
program.exec_and_exit();
}
// --------- IMPORTANT ---------
// Define `CustomSetup` (inferred from `custom_setup`)
// Package part of the program construction logic into this type for modular management
#[program_setup]
fn custom_setup(program: &mut Program<ThisProgram>) {
program.with_dispatcher(CMD1);
program.with_dispatcher(CMD2);
program.with_dispatcher(CMD3);
program.with_dispatcher(CMD4);
program.with_dispatcher(CMD5);
}
// --------- IMPORTANT ---------
dispatcher!("1", CMD1 => Entry1);
dispatcher!("2", CMD2 => Entry2);
dispatcher!("3", CMD3 => Entry3);
dispatcher!("4", CMD4 => Entry4);
dispatcher!("5", CMD5 => Entry5);
gen_program!();
|