1930: Consistent From<Yaml> for ArgGroup r=CreepySkeleton a=pksunkara



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
This commit is contained in:
bors[bot] 2020-05-15 13:04:40 +00:00 committed by GitHub
commit 097bec669b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 19 deletions

View file

@ -2190,7 +2190,7 @@ impl<'a> From<&'a Yaml> for App<'a> {
}
if let Some(v) = yaml["groups"].as_vec() {
for ag_yaml in v {
a = a.group(ArgGroup::from(ag_yaml.as_hash().unwrap()));
a = a.group(ArgGroup::from(ag_yaml));
}
}

View file

@ -414,22 +414,6 @@ impl<'a> Debug for ArgGroup<'a> {
}
}
#[cfg(feature = "yaml")]
impl<'a> From<&'a Yaml> for ArgGroup<'a> {
/// Creates a new instance of `ArgGroup` from a .yml (YAML) file.
///
/// # Examples
///
/// ```ignore
/// # use clap::{ArgGroup, load_yaml};
/// let yml = load_yaml!("group.yml");
/// let ag = ArgGroup::from(yml);
/// ```
fn from(y: &'a Yaml) -> Self {
ArgGroup::from(y.as_hash().unwrap())
}
}
impl<'a, 'z> From<&'z ArgGroup<'a>> for ArgGroup<'a> {
fn from(g: &'z ArgGroup<'a>) -> Self {
ArgGroup {
@ -445,8 +429,18 @@ impl<'a, 'z> From<&'z ArgGroup<'a>> for ArgGroup<'a> {
}
#[cfg(feature = "yaml")]
impl<'a> From<&'a yaml_rust::yaml::Hash> for ArgGroup<'a> {
fn from(b: &'a yaml_rust::yaml::Hash) -> Self {
impl<'a> From<&'a Yaml> for ArgGroup<'a> {
/// Creates a new instance of `ArgGroup` from a .yml (YAML) file.
///
/// # Examples
///
/// ```ignore
/// # use clap::{ArgGroup, load_yaml};
/// let yml = load_yaml!("group.yml");
/// let ag = ArgGroup::from(yml);
/// ```
fn from(y: &'a Yaml) -> Self {
let b = y.as_hash().expect("ArgGroup::from::<Yaml> expects a table");
// We WANT this to panic on error...so expect() is good.
let mut a = ArgGroup::default();
let group_settings = if b.len() == 1 {

View file

@ -29,6 +29,7 @@ pub use crate::{
};
#[cfg(feature = "yaml")]
#[cfg_attr(feature = "yaml", doc(hidden))]
pub use yaml_rust::YamlLoader;
#[cfg(feature = "derive")]