From b4e938c2a032ae7185febc84bfe27d77b4863b4c Mon Sep 17 00:00:00 2001 From: Alexandru Macovei Date: Sun, 24 Jun 2018 03:33:01 +0300 Subject: [PATCH] convert output colorizer from fn to closure --- src/main.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2dd78bbc..e66f7cd0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 { @@ -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()) )); @@ -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); }