mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 23:02:38 +00:00
`ls
: Changed unwrap_or and
or
option handling to lazy evaluated
unwrap_or_else
and
or_else
` (#6609)
* Changed unwrap_or and option handling to lazy evaluation * Clippy fixes
This commit is contained in:
parent
66e0989526
commit
e4749381f9
2 changed files with 3 additions and 3 deletions
|
@ -169,7 +169,7 @@ pub(crate) fn color_name(
|
|||
// Use fn get_metadata_with_deref_opt instead of get_metadata() here because ls
|
||||
// should not exit with an err, if we are unable to obtain the target_metadata
|
||||
let md_res = get_metadata_with_deref_opt(&target.p_buf, path.must_dereference);
|
||||
let md = md_res.or(path.p_buf.symlink_metadata());
|
||||
let md = md_res.or_else(|_| path.p_buf.symlink_metadata());
|
||||
style_manager.apply_style_based_on_metadata(path, md.ok().as_ref(), name, wrap)
|
||||
} else {
|
||||
let md_option = path.get_metadata(out);
|
||||
|
|
|
@ -697,7 +697,7 @@ fn extract_quoting_style(options: &clap::ArgMatches, show_control: bool) -> Quot
|
|||
Some(qs) => return qs,
|
||||
None => eprintln!(
|
||||
"{}: Ignoring invalid value of environment variable QUOTING_STYLE: '{}'",
|
||||
std::env::args().next().unwrap_or("ls".to_string()),
|
||||
std::env::args().next().unwrap_or_else(|| "ls".to_string()),
|
||||
style
|
||||
),
|
||||
}
|
||||
|
@ -3332,7 +3332,7 @@ fn display_item_name(
|
|||
}
|
||||
|
||||
fn create_hyperlink(name: &str, path: &PathData) -> String {
|
||||
let hostname = hostname::get().unwrap_or(OsString::from(""));
|
||||
let hostname = hostname::get().unwrap_or_else(|_| OsString::from(""));
|
||||
let hostname = hostname.to_string_lossy();
|
||||
|
||||
let absolute_path = fs::canonicalize(&path.p_buf).unwrap_or_default();
|
||||
|
|
Loading…
Reference in a new issue