pub type FnSubArg<'a> = &'a dyn Fn(&str, &str);Expand description
Type for a closure for an argument.
Using RefCell to change the captured environment is required. While it isn’t strictly required, it is required if we want to reuse the closure.
(technically, this is a function pointer, not a closure, but the syntax creates the function pointer)
Example:
use std::cell::RefCell;
use getoptions_long::*;
let args: Vec<String> = vec!["-t", "--toggle", "-t", "-t"].into_iter().map(|x| x.to_string()).collect();
let flag = RefCell::new(false);
let result = get_options(&mut [
Opt::SubSwitch("t|toggle", &|_| { flag.replace_with(|t| !*t ); }),
], &args);
assert!(!flag.into_inner());