Skip to content

Commit

Permalink
fix: get_args return an iterator of &Id
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-go committed Oct 3, 2022
1 parent 15ff335 commit d192d98
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/builder/arg_group.rs
Expand Up @@ -199,8 +199,8 @@ impl ArgGroup {
///
/// assert_eq!(group.get_args(), ["f", "c"]);
/// ```
pub fn get_args(self) -> Vec<Id> {
self.args
pub fn get_args(&self) -> impl Iterator<Item = &Id> {
self.args.iter()
}

/// Allows more than one of the [`Arg`]s in this group to be used. (Default: `false`)
Expand Down Expand Up @@ -587,6 +587,10 @@ mod test {
let args: Vec<Id> = vec!["a1".into(), "a4".into()];
let grp = ArgGroup::new("program").args(&args);

assert_eq!(grp.get_args(), args);
let mut pos = 0;
for arg in grp.get_args() {
assert_eq!(*arg, args[pos]);
pos += 1;
}
}
}

0 comments on commit d192d98

Please sign in to comment.