/// Create a new `CommandRepl` from the given application configuration.
Create a new `CommandRepl` from the given application configuration.
Create a new ` CommandRepl ` from the given application configuration .
pub fn from_config(config: &Config) -> Result<Arc<Self>, Box<dyn Error>> {
        fn create_command_handler<H>(
            config: &Config,
        ) -> Result<Arc<dyn CommandHandler>, Box<dyn Error>>
        where
            H: 'static + CommandHandler,
        {
            let handler = H::new(config)?;
            Ok(Arc::new(handler))
        }
        let mut dispatcher = Self::default();
        let factories = [
            create_command_handler::<CanteenCommandHandler>,
            create_command_handler::<DrinkCommandHandler>,
            create_command_handler::<HelpCommandHandler>,
            create_command_handler::<MeowCommandHandler>,
            create_command_handler::<Twd2CommandHandler>,
        ];
        for f in factories {
            let handler = f(config)?;
            dispatcher.handlers.push(handler);
        }
        Ok(Arc::new(dispatcher))
    }
pub fn from_config ( config : & Config ) -> Result < Arc < Self > , Box < dyn Error > > { fn create_command_handler < H > ( config : & Config , ) -> Result < Arc < dyn CommandHandler > , Box < dyn Error > > where H : ' static + CommandHandler , { let handler = H :: new ( config ) ? ; Ok ( Arc :: new ( handler ) ) } let mut dispatcher = Self :: default ( ) ; let factories = [ create_command_handler :: < CanteenCommandHandler > , create_command_handler :: < DrinkCommandHandler > , create_command_handler :: < HelpCommandHandler > , create_command_handler :: < MeowCommandHandler > , create_command_handler :: < Twd2CommandHandler > , ] ; for f in factories { let handler = f ( config ) ? ; dispatcher . handlers . push ( handler ) ; } Ok ( Arc :: new ( dispatcher ) ) }
Create a new `CommandRepl` from the given application configuration.
Create a new ` CommandRepl ` from the given application configuration .
config
&Config