use std::collections::HashMap; use dynfmt::{Argument, FormatArgs}; pub struct DropFormatArgs { positional: Vec, map: HashMap<&'static str, String>, } impl DropFormatArgs { pub fn new(launch_string: String, working_dir: &String, executable_name: &String, absolute_executable_name: String) -> Self { let mut positional = Vec::new(); let mut map: HashMap<&'static str, String> = HashMap::new(); positional.push(launch_string); map.insert("dir", working_dir.to_string()); map.insert("exe", executable_name.to_string()); map.insert("abs_exe", absolute_executable_name); Self { positional, map } } } impl FormatArgs for DropFormatArgs { fn get_index(&self, index: usize) -> Result>, ()> { Ok(self.positional.get(index).map(|arg| arg as Argument<'_>)) } fn get_key(&self, key: &str) -> Result>, ()> { Ok(self.map.get(key).map(|arg| arg as Argument<'_>)) } }