Skip to content

Commit

Permalink
fix: Method 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 4d4126a commit 88f0c5f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/builder/arg_group.rs
Original file line number Diff line number Diff line change
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 88f0c5f

Please sign in to comment.