diff --git a/src/build/app/mod.rs b/src/build/app/mod.rs index abbc22e7..fada5a99 100644 --- a/src/build/app/mod.rs +++ b/src/build/app/mod.rs @@ -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)); } } diff --git a/src/build/arg_group.rs b/src/build/arg_group.rs index c9d93199..a22dfa28 100644 --- a/src/build/arg_group.rs +++ b/src/build/arg_group.rs @@ -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:: 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 { diff --git a/src/lib.rs b/src/lib.rs index 997cbd02..17fd2cd3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,6 +29,7 @@ pub use crate::{ }; #[cfg(feature = "yaml")] +#[cfg_attr(feature = "yaml", doc(hidden))] pub use yaml_rust::YamlLoader; #[cfg(feature = "derive")]