use env_logger; use macro_machines::def_machine_debug; def_machine_debug!{ machine M { STATES [ state R () state S () state T () ] EVENTS [ event ToR <*> => () event ToT <*> => () event ToS => () ] EXTENDED [] initial_state: S } } fn main () { use std::io::Write; use macro_machines::{HandleEventException, MachineDotfile}; let example_name = std::env::current_exe().unwrap().file_name().unwrap() .to_str().unwrap().to_string(); println!("{example_name}: main..."); env_logger::Builder::new() .filter_level (log::LevelFilter::Trace) .parse_default_env() .init(); M::report_sizes(); let dotfile_name = format!("{example_name}.dot"); let mut f = std::fs::File::create (dotfile_name).unwrap(); f.write_all (M::dotfile_show_defaults().as_bytes()).unwrap(); drop (f); let mut m = M::initial(); println!("m: {m:?}"); m.handle_event (EventId::ToR.into()).unwrap(); println!("m: {m:?}"); assert_eq!(m.handle_event (EventId::ToS.into()), Err (HandleEventException::WrongState)); println!("{example_name}: ...main"); }