diff --git a/embassy/demos/common/src/demo_menu.rs b/embassy/demos/common/src/demo_menu.rs index bde29d54419ff85e7c4238f6a2e124078c2c0578..0705cd9980e876e437b49b67b3362375d8b364ae 100644 --- a/embassy/demos/common/src/demo_menu.rs +++ b/embassy/demos/common/src/demo_menu.rs @@ -80,15 +80,15 @@ It contains multiple paragraphs and should be preceeded by the parameter list. exit: Some(exit_root), }; -fn enter_root(_menu: &Menu<BufOutput>, context: &mut BufOutput) { +fn enter_root(context: &mut BufOutput) { writeln!(context, "In enter_root").unwrap(); } -fn exit_root(_menu: &Menu<BufOutput>, context: &mut BufOutput) { +fn exit_root(context: &mut BufOutput) { writeln!(context, "In exit_root").unwrap(); } -fn select_foo<'a>(_menu: &Menu<BufOutput>, item: &Item<BufOutput>, args: &[&str], context: &mut BufOutput) { +fn select_foo<'a>(item: &Item<BufOutput>, args: &[&str], context: &mut BufOutput) { writeln!(context, "In select_foo. Args = {:?}", args).unwrap(); writeln!( context, @@ -122,24 +122,23 @@ fn select_foo<'a>(_menu: &Menu<BufOutput>, item: &Item<BufOutput>, args: &[&str] .unwrap(); } -fn select_bar<'a>(_menu: &Menu<BufOutput>, _item: &Item<BufOutput>, args: &[&str], context: &mut BufOutput) { +fn select_bar<'a>(_item: &Item<BufOutput>, args: &[&str], context: &mut BufOutput) { writeln!(context, "In select_bar. Args = {:?}", args).unwrap(); } -fn enter_sub(_menu: &Menu<BufOutput>, context: &mut BufOutput) { +fn enter_sub(context: &mut BufOutput) { writeln!(context, "In enter_sub").unwrap(); } -fn exit_sub(_menu: &Menu<BufOutput>, context: &mut BufOutput) { +fn exit_sub(context: &mut BufOutput) { writeln!(context, "In exit_sub").unwrap(); } -fn select_baz<'a>(_menu: &Menu<BufOutput>, _item: &Item<BufOutput>, args: &[&str], context: &mut BufOutput) { +fn select_baz<'a>(_item: &Item<BufOutput>, args: &[&str], context: &mut BufOutput) { writeln!(context, "In select_baz: Args = {:?}", args).unwrap(); } fn select_quux<'a>( - _menu: &Menu<BufOutput>, _item: &Item<BufOutput>, args: &[&str], context: &mut BufOutput, diff --git a/embassy/demos/common/src/menu.rs b/embassy/demos/common/src/menu.rs index f4b85c0b21bbaa23e3c55b0e7448c0971b1c4cd7..313f694a3047ab3a82598e5d624f224a12b48b0e 100644 --- a/embassy/demos/common/src/menu.rs +++ b/embassy/demos/common/src/menu.rs @@ -10,10 +10,10 @@ #![deny(missing_docs)] /// The type of function we call when we enter/exit a menu. -pub type MenuCallbackFn<T> = fn(menu: &Menu<T>, context: &mut T); +pub type MenuCallbackFn<T> = fn(context: &mut T); /// The type of function we call when we a valid command has been entered. -pub type ItemCallbackFn<T> = fn(menu: &Menu<T>, item: &Item<T>, args: &[&str], context: &mut T); +pub type ItemCallbackFn<T> = fn(item: &Item<T>, args: &[&str], context: &mut T); #[derive(Debug)] /// Describes a parameter to the command @@ -245,7 +245,7 @@ where /// `write!` to the context, which it will do for all text output. pub fn new(menu: &'a Menu<'a, T>, buffer: &'a mut [u8], mut context: T) -> Runner<'a, T> { if let Some(cb_fn) = menu.entry { - cb_fn(menu, &mut context); + cb_fn(&mut context); } let mut r = Runner { menus: [Some(menu), None, None, None], @@ -385,7 +385,6 @@ where &mut self.context, function, parameters, - menu, item, command_line, ), @@ -552,7 +551,6 @@ where context: &mut T, callback_function: ItemCallbackFn<T>, parameters: &[Parameter], - parent_menu: &Menu<T>, item: &Item<T>, command: &str, ) { @@ -622,7 +620,6 @@ where writeln!(context, "Error: Too many arguments given").unwrap(); } else { callback_function( - parent_menu, item, &argument_buffer[0..argument_count], context, @@ -631,7 +628,7 @@ where } else { // Definitely no arguments if mandatory_parameter_count == 0 { - callback_function(parent_menu, item, &[], context); + callback_function(item, &[], context); } else { writeln!(context, "Error: Insufficient arguments given").unwrap(); } @@ -643,7 +640,7 @@ where mod tests { use super::*; - fn dummy(_menu: &Menu<u32>, _item: &Item<u32>, _args: &[&str], _context: &mut u32) {} + fn dummy(_item: &Item<u32>, _args: &[&str], _context: &mut u32) {} #[test] fn find_arg_mandatory() {