Skip to content

Commit

Permalink
chore: clippy run
Browse files Browse the repository at this point in the history
  • Loading branch information
kbknapp committed Aug 20, 2016
1 parent 565d21f commit 7bc1b4b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions src/app/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl<'a> Help<'a> {
debugln!("fn=Help::write_help;");
if let Some(h) = parser.meta.help_str {
try!(write!(self.writer, "{}", h).map_err(Error::from));
} else if let Some(ref tmpl) = parser.meta.template {
} else if let Some(tmpl) = parser.meta.template {
try!(self.write_templated_help(&parser, tmpl));
} else {
try!(self.write_default_help(&parser));
Expand Down Expand Up @@ -282,7 +282,7 @@ impl<'a> Help<'a> {
if !arg.takes_value() {
return Ok(());
}
if let Some(ref vec) = arg.val_names() {
if let Some(vec) = arg.val_names() {
let mut it = vec.iter().peekable();
while let Some((_, val)) = it.next() {
try!(color!(self, "<{}>", val, good));
Expand Down Expand Up @@ -524,7 +524,7 @@ impl<'a> Help<'a> {

fn spec_vals(&self, a: &ArgWithDisplay) -> String {
debugln!("fn=spec_vals;");
if let Some(ref pv) = a.default_val() {
if let Some(pv) = a.default_val() {
debugln!("Writing defaults");
return format!(" [default: {}] {}",
if self.color {
Expand Down Expand Up @@ -562,7 +562,7 @@ impl<'a> Help<'a> {
});
} else if !self.hide_pv {
debugln!("Writing values");
if let Some(ref pv) = a.possible_vals() {
if let Some(pv) = a.possible_vals() {
debugln!("Possible vals...{:?}", pv);
return if self.color {
format!(" [values: {}]",
Expand Down Expand Up @@ -943,7 +943,7 @@ impl<'a> Help<'a> {
parser.meta.pre_help.unwrap_or("unknown before-help")));
}
// Unknown tag, write it back.
ref r => {
r => {
try!(self.writer.write(b"{"));
try!(self.writer.write(r));
try!(self.writer.write(b"}"));
Expand Down
16 changes: 8 additions & 8 deletions src/app/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ impl<'a, 'b> Parser<'a, 'b>
// Firt we verify that the index highest supplied index, is equal to the number of
// positional arguments to verify there are no gaps (i.e. supplying an index of 1 and 3
// but no 2)
if let Some((idx, ref p)) = self.positionals.iter().rev().next() {
if let Some((idx, p)) = self.positionals.iter().rev().next() {
debug_assert!(!(idx != self.positionals.len()),
format!("Found positional argument \"{}\" who's index is {} but there are \
only {} positional arguments defined",
Expand Down Expand Up @@ -621,10 +621,10 @@ impl<'a, 'b> Parser<'a, 'b>
self.settings.is_set(AppSettings::NeedsSubcommandHelp) {
let cmds: Vec<OsString> = it.map(|c| c.into()).collect();
let mut help_help = false;
let mut bin_name = format!("{}", self.meta
.bin_name
.as_ref()
.unwrap_or(&self.meta.name.clone()));
let mut bin_name = self.meta
.bin_name
.as_ref()
.unwrap_or(&self.meta.name).clone();
let mut sc = {
let mut sc: &Parser = self;
for (i, cmd) in cmds.iter().enumerate() {
Expand Down Expand Up @@ -754,7 +754,7 @@ impl<'a, 'b> Parser<'a, 'b>
if let Some(o) = self.opts.iter().filter(|o| &o.name == &a).next() {
try!(self.validate_required(matcher));
reqs_validated = true;
let should_err = if let Some(ref v) = matcher.0.args.get(&*o.name) {
let should_err = if let Some(v) = matcher.0.args.get(&*o.name) {
v.vals.is_empty() && !(o.min_vals.is_some() && o.min_vals.unwrap() == 0)
} else {
true
Expand Down Expand Up @@ -1389,7 +1389,7 @@ impl<'a, 'b> Parser<'a, 'b>
if self.is_set(AppSettings::StrictUtf8) && val.to_str().is_none() {
return Err(Error::invalid_utf8(&*self.create_current_usage(matcher), self.color()));
}
if let Some(ref p_vals) = arg.possible_vals() {
if let Some(p_vals) = arg.possible_vals() {
let val_str = val.to_string_lossy();
if !p_vals.contains(&&*val_str) {
return Err(Error::invalid_value(val_str,
Expand All @@ -1403,7 +1403,7 @@ impl<'a, 'b> Parser<'a, 'b>
matcher.contains(&*arg.name()) {
return Err(Error::empty_value(arg, &*self.create_current_usage(matcher), self.color()));
}
if let Some(ref vtor) = arg.validator() {
if let Some(vtor) = arg.validator() {
if let Err(e) = vtor(val.to_string_lossy().into_owned()) {
return Err(Error::value_validation(e, self.color()));
}
Expand Down
8 changes: 4 additions & 4 deletions src/args/arg_matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<'a> ArgMatches<'a> {
/// [`ArgMatches::values_of`]: ./struct.ArgMatches.html#method.values_of
/// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html
pub fn value_of<S: AsRef<str>>(&self, name: S) -> Option<&str> {
if let Some(ref arg) = self.args.get(name.as_ref()) {
if let Some(arg) = self.args.get(name.as_ref()) {
if let Some(v) = arg.vals.values().nth(0) {
return Some(v.to_str().expect(INVALID_UTF8));
}
Expand Down Expand Up @@ -208,7 +208,7 @@ impl<'a> ArgMatches<'a> {
/// [`Values`]: ./struct.Values.html
/// [`Iterator`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html
pub fn values_of<S: AsRef<str>>(&'a self, name: S) -> Option<Values<'a>> {
if let Some(ref arg) = self.args.get(name.as_ref()) {
if let Some(arg) = self.args.get(name.as_ref()) {
fn to_str_slice(o: &OsString) -> &str {
o.to_str().expect(INVALID_UTF8)
}
Expand Down Expand Up @@ -240,7 +240,7 @@ impl<'a> ArgMatches<'a> {
/// assert_eq!(itr.next(), None);
/// ```
pub fn values_of_lossy<S: AsRef<str>>(&'a self, name: S) -> Option<Vec<String>> {
if let Some(ref arg) = self.args.get(name.as_ref()) {
if let Some(arg) = self.args.get(name.as_ref()) {
return Some(arg.vals
.values()
.map(|v| v.to_string_lossy().into_owned())
Expand Down Expand Up @@ -284,7 +284,7 @@ impl<'a> ArgMatches<'a> {
&*o
}
let to_str_slice: fn(&'a OsString) -> &'a OsStr = to_str_slice; // coerce to fn pointer
if let Some(ref arg) = self.args.get(name.as_ref()) {
if let Some(arg) = self.args.get(name.as_ref()) {
return Some(OsValues { iter: arg.vals.values().map(to_str_slice) });
}
None
Expand Down
12 changes: 6 additions & 6 deletions src/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ end
};

let mut buffer = detect_subcommand_function;
gen_fish_inner(command, &self, vec![], &mut buffer, has_subcommands);
gen_fish_inner(command, self, vec![], &mut buffer, has_subcommands);
w!(buf, buffer.as_bytes());
}
}
Expand All @@ -235,7 +235,7 @@ pub fn get_all_subcommands(p: &Parser) -> Vec<String> {
}
subcmds.push(sc.p.meta.name.clone());
}
for sc_v in p.subcommands.iter().map(|ref s| get_all_subcommands(&s.p)) {
for sc_v in p.subcommands.iter().map(|s| get_all_subcommands(&s.p)) {
subcmds.extend(sc_v);
}
subcmds.sort();
Expand Down Expand Up @@ -269,7 +269,7 @@ pub fn get_all_subcommand_paths(p: &Parser, first: bool) -> Vec<String> {
}
}
}
for sc_v in p.subcommands.iter().map(|ref s| get_all_subcommand_paths(&s.p, false)) {
for sc_v in p.subcommands.iter().map(|s| get_all_subcommand_paths(&s.p, false)) {
subcmds.extend(sc_v);
}
subcmds
Expand All @@ -279,10 +279,10 @@ fn vals_for(o: &OptBuilder) -> String {
use args::AnyArg;
let mut ret = String::new();
let mut needs_quotes = true;
if let Some(ref vals) = o.possible_vals() {
if let Some(vals) = o.possible_vals() {
needs_quotes = false;
ret = format!("$(compgen -W \"{}\" -- ${{cur}})", vals.join(" "));
} else if let Some(ref vec) = o.val_names() {
} else if let Some(vec) = o.val_names() {
let mut it = vec.iter().peekable();
while let Some((_, val)) = it.next() {
ret = format!("{}<{}>{}", ret, val,
Expand Down Expand Up @@ -321,7 +321,7 @@ fn vals_for(o: &OptBuilder) -> String {
ret
}

fn gen_fish_inner(root_command: &String,
fn gen_fish_inner(root_command: &str,
comp_gen: &ComplGen,
parent_cmds: Vec<&String>,
buffer: &mut String,
Expand Down

0 comments on commit 7bc1b4b

Please sign in to comment.