Skip to content

Commit

Permalink
convert output colorizer from fn to closure
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmaco committed Jun 24, 2018
1 parent c6a83f5 commit b4e938c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,7 @@ fn print_dependency<'a>(
allow_partial_results);

let unsafe_found = counters.has_unsafe();
// TODO: can this be a closure ?
fn colorize(unsafe_found: bool, s: String) -> ColoredString {
let colorize = |s: String| {
if unsafe_found {
s.red().bold()
} else {
Expand All @@ -682,7 +681,7 @@ fn print_dependency<'a>(

let rad = if unsafe_found { "☢" } else { "" };

let dep_name = colorize(unsafe_found, format!("{}", format.display(
let dep_name = colorize(format!("{}", format.display(
package.id,
package.pack.manifest().metadata())
));
Expand All @@ -695,9 +694,9 @@ fn print_dependency<'a>(
counters.itemtraits.unsafe_num,
counters.methods.unsafe_num,
);
println!("{}{} {} {}", treevines, dep_name, colorize(unsafe_found, compact_unsafe_info), rad);
println!("{}{} {} {}", treevines, dep_name, colorize(compact_unsafe_info), rad);
} else {
let unsafe_info = colorize(unsafe_found, table_row(&counters));
let unsafe_info = colorize(table_row(&counters));
println!("{} {: <1} {}{}", unsafe_info, rad, treevines, dep_name);
}

Expand Down

0 comments on commit b4e938c

Please sign in to comment.