refactor: Remove vec_map dependency

Doesn't look like this dependency is buying us anything at this point,
so removing it.
This commit is contained in:
Ed Page 2021-09-17 13:45:00 -05:00
parent 76859b16bb
commit b3847b76c4
5 changed files with 7 additions and 10 deletions

View file

@ -65,7 +65,6 @@ bitflags = "1.2"
textwrap = { version = "0.14.0", default-features = false, features = [] }
indexmap = "1.0"
os_str_bytes = "4.1"
vec_map = "0.8"
strsim = { version = "0.10", optional = true }
yaml-rust = { version = "0.4.1", optional = true }
atty = { version = "0.2", optional = true }

View file

@ -31,7 +31,6 @@ use yaml_rust::Yaml;
// Internal
use crate::{
build::{arg::settings::ArgFlags, usage_parser::UsageParser},
util::VecMap,
util::{Id, Key},
INTERNAL_ERROR_MSG,
};
@ -111,7 +110,7 @@ pub struct Arg<'help> {
pub(crate) validator_os: Option<Arc<Mutex<ValidatorOs<'help>>>>,
pub(crate) val_delim: Option<char>,
pub(crate) default_vals: Vec<&'help OsStr>,
pub(crate) default_vals_ifs: VecMap<(Id, Option<&'help OsStr>, Option<&'help OsStr>)>,
pub(crate) default_vals_ifs: Vec<(Id, Option<&'help OsStr>, Option<&'help OsStr>)>,
pub(crate) default_missing_vals: Vec<&'help OsStr>,
#[cfg(feature = "env")]
pub(crate) env: Option<(&'help OsStr, Option<OsString>)>,
@ -2938,9 +2937,7 @@ impl<'help> Arg<'help> {
val: Option<&'help OsStr>,
default: Option<&'help OsStr>,
) -> Self {
let l = self.default_vals_ifs.len();
self.default_vals_ifs
.insert(l, (arg_id.into(), val, default));
self.default_vals_ifs.push((arg_id.into(), val, default));
self.takes_value(true)
}

View file

@ -215,7 +215,7 @@ impl<'help, 'app, 'parser, 'writer> Help<'help, 'app, 'parser, 'writer> {
longest = longest.max(display_width(arg.to_string().as_str()));
debug!("Help::write_args: New Longest...{}", longest);
}
let btm = ord_m.entry(arg.disp_ord).or_insert(BTreeMap::new());
let btm = ord_m.entry(arg.disp_ord).or_insert_with(BTreeMap::new);
// Formatting key like this to ensure that:
// 1. Argument has long flags are printed just after short flags.
@ -873,7 +873,9 @@ impl<'help, 'app, 'parser, 'writer> Help<'help, 'app, 'parser, 'writer> {
.iter()
.filter(|subcommand| should_show_subcommand(subcommand))
{
let btm = ord_m.entry(subcommand.disp_ord).or_insert(BTreeMap::new());
let btm = ord_m
.entry(subcommand.disp_ord)
.or_insert_with(BTreeMap::new);
let mut sc_str = String::new();
sc_str.push_str(
&subcommand

View file

@ -1655,7 +1655,7 @@ impl<'help, 'app> Parser<'help, 'app> {
if !arg.default_vals_ifs.is_empty() {
debug!("Parser::add_value: has conditional defaults");
if matcher.get(&arg.id).is_none() {
for (id, val, default) in arg.default_vals_ifs.values() {
for (id, val, default) in arg.default_vals_ifs.iter() {
let add = if let Some(a) = matcher.get(id) {
if let Some(v) = val {
a.vals_flatten().any(|value| v == value)

View file

@ -11,7 +11,6 @@ pub use self::fnv::Key;
#[cfg(feature = "env")]
pub(crate) use self::str_to_bool::str_to_bool;
pub(crate) use self::{graph::ChildGraph, id::Id};
pub(crate) use vec_map::VecMap;
#[cfg(feature = "color")]
pub(crate) use termcolor;