refactor: clippy run

This commit is contained in:
Kevin K 2016-06-08 00:10:56 -04:00
parent fe0818b854
commit 1bfae42eaf
5 changed files with 27 additions and 26 deletions

View file

@ -132,7 +132,7 @@ impl<'a> Help<'a> {
use_stderr: stderr,
when: parser.color(),
};
Self::new(w, nlh, hide_v, color, cizer).write_help(&parser)
Self::new(w, nlh, hide_v, color, cizer).write_help(parser)
}
/// Writes the parser help to the wrapped stream.
@ -485,6 +485,7 @@ impl<'a> Help<'a> {
impl<'a> Help<'a> {
/// Writes help for all arguments (options, flags, args, subcommands)
/// including titles of a Parser Object to the wrapped stream.
#[cfg_attr(feature = "lints", allow(useless_let_if_seq))]
pub fn write_all_args(&mut self, parser: &Parser) -> ClapResult<()> {
let flags = parser.has_flags();

View file

@ -76,8 +76,7 @@ macro_rules! _handle_group_reqs{
use args::AnyArg;
debugln!("macro=_handle_group_reqs!;");
for grp in $me.groups.values() {
let mut found = false;
if grp.args.contains(&$arg.name()) {
let found = if grp.args.contains(&$arg.name()) {
vec_remove!($me.required, &$arg.name());
if let Some(ref reqs) = grp.requires {
$me.required.extend(reqs);
@ -85,8 +84,10 @@ macro_rules! _handle_group_reqs{
if let Some(ref bl) = grp.conflicts {
$me.blacklist.extend(bl);
}
found = true; // What if arg is in more than one group with different reqs?
}
true // What if arg is in more than one group with different reqs?
} else {
false
};
if found {
vec_remove_all!($me.required, &grp.args);
debugln!("Adding args from group to blacklist...{:?}", grp.args);

View file

@ -840,7 +840,7 @@ impl<'a, 'b> App<'a, 'b> {
/// ```
/// [`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
pub fn write_help<W: Write>(&self, w: &mut W) -> ClapResult<()> {
Help::write_app_help(w, &self)
Help::write_app_help(w, self)
}
/// Writes the version message to the user to a [`io::Write`] object

View file

@ -138,10 +138,10 @@ impl<'a, 'b> Parser<'a, 'b>
argument\n\n\tPerhaps try .multiple(true) to allow one positional argument \
to take multiple values",
a.name));
let pb = PosBuilder::from_arg(&a, i as u64, &mut self.required);
let pb = PosBuilder::from_arg(a, i as u64, &mut self.required);
self.positionals.insert(i, pb);
} else if a.is_set(ArgSettings::TakesValue) {
let mut ob = OptBuilder::from_arg(&a, &mut self.required);
let mut ob = OptBuilder::from_arg(a, &mut self.required);
if self.settings.is_set(AppSettings::DeriveDisplayOrder) && a.disp_ord == 999 {
ob.disp_ord = if self.settings.is_set(AppSettings::UnifiedHelpMessage) {
self.flags.len() + self.opts.len()
@ -309,7 +309,7 @@ impl<'a, 'b> Parser<'a, 'b>
c_opt.dedup();
grps.dedup();
let mut args_in_groups = vec![];
for g in grps.iter() {
for g in &grps {
for a in self.arg_names_in_group(g).into_iter() {
args_in_groups.push(a);
}
@ -329,11 +329,10 @@ impl<'a, 'b> Parser<'a, 'b>
}
debugln!("args_in_groups={:?}", args_in_groups);
for (_, s) in pmap {
if !args_in_groups.is_empty() {
if args_in_groups.contains(&&*s) {
continue;
}
if (!args_in_groups.is_empty()) && (args_in_groups.contains(&&*s)) {
continue;
}
ret_val.push_back(s);
}
macro_rules! write_arg {
@ -1258,7 +1257,7 @@ impl<'a, 'b> Parser<'a, 'b>
debugln!("groups contains it...");
for n in self.arg_names_in_group(name) {
debugln!("Checking arg '{}' in group...", n);
if matcher.contains(&n) {
if matcher.contains(n) {
debugln!("matcher contains it...");
return Err(build_err!(self, n, matcher));
}
@ -1470,7 +1469,7 @@ impl<'a, 'b> Parser<'a, 'b>
debugln!("fn=create_usage;");
let mut usage = String::with_capacity(75);
usage.push_str("USAGE:\n ");
usage.push_str(&self.create_usage_no_title(&used));
usage.push_str(&self.create_usage_no_title(used));
usage
}
@ -1606,11 +1605,11 @@ impl<'a, 'b> Parser<'a, 'b>
}
pub fn write_help<W: Write>(&self, w: &mut W) -> ClapResult<()> {
Help::write_parser_help(w, &self)
Help::write_parser_help(w, self)
}
pub fn write_help_err<W: Write>(&self, w: &mut W) -> ClapResult<()> {
Help::write_parser_help_to_stderr(w, &self)
Help::write_parser_help_to_stderr(w, self)
}
fn add_defaults(&mut self, matcher: &mut ArgMatcher<'a>) -> ClapResult<()> {

View file

@ -55,24 +55,24 @@ impl OsStrExt2 for OsStr {
fn split_at_byte(&self, byte: u8) -> (&OsStr, &OsStr) {
for (i, b) in self.as_bytes().iter().enumerate() {
if b == &byte {
return (&OsStr::from_bytes(&self.as_bytes()[..i]),
&OsStr::from_bytes(&self.as_bytes()[i + 1..]));
return (OsStr::from_bytes(&self.as_bytes()[..i]),
OsStr::from_bytes(&self.as_bytes()[i + 1..]));
}
}
(&*self, &OsStr::from_bytes(&self.as_bytes()[self.len_()..self.len_()]))
(&*self, OsStr::from_bytes(&self.as_bytes()[self.len_()..self.len_()]))
}
fn trim_left_matches(&self, byte: u8) -> &OsStr {
for (i, b) in self.as_bytes().iter().enumerate() {
if b != &byte {
return &OsStr::from_bytes(&self.as_bytes()[i..]);
return OsStr::from_bytes(&self.as_bytes()[i..]);
}
}
&*self
}
fn split_at(&self, i: usize) -> (&OsStr, &OsStr) {
(&OsStr::from_bytes(&self.as_bytes()[..i]), &OsStr::from_bytes(&self.as_bytes()[i..]))
(OsStr::from_bytes(&self.as_bytes()[..i]), OsStr::from_bytes(&self.as_bytes()[i..]))
}
fn len_(&self) -> usize {
@ -109,10 +109,10 @@ impl<'a> Iterator for OsSplit<'a> {
for b in &self.val[start..] {
self.pos += 1;
if *b == self.sep {
return Some(&OsStr::from_bytes(&self.val[start..self.pos - 1]));
return Some(OsStr::from_bytes(&self.val[start..self.pos - 1]));
}
}
Some(&OsStr::from_bytes(&self.val[start..]))
Some(OsStr::from_bytes(&self.val[start..]))
}
fn size_hint(&self) -> (usize, Option<usize>) {
let mut count = 0;
@ -137,9 +137,9 @@ impl<'a> DoubleEndedIterator for OsSplit<'a> {
for b in self.val[..self.pos].iter().rev() {
self.pos -= 1;
if *b == self.sep {
return Some(&OsStr::from_bytes(&self.val[self.pos + 1..start]));
return Some(OsStr::from_bytes(&self.val[self.pos + 1..start]));
}
}
Some(&OsStr::from_bytes(&self.val[..start]))
Some(OsStr::from_bytes(&self.val[..start]))
}
}