Use references instead of values
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by sharkdp · committed by sharkdp · parent f7910c1 · Browse files · 3 files·+9 added−8 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+9 added−8 removed
- other:+9 added−8 removed
Provenance
- Commit
c8d4ec8- Tree
70297ce- Author
sharkdp <davidpeter@web.de>- Committer
sharkdp <davidpeter@web.de>- Parent
f7910c1
3 files changed+9 added−8 removed
modified:src/main.rs+7 added-6 removed
88 unmodified lines89 #[cfg(not(target_family = "unix"))]90 let is_executable = |p: &std::path::PathBuf| {false};91 92 if let Some(ref ls_colors) = config.ls_colors {93+ let default_style = ansi_term::Style::default();94+95 let mut component_path = base.to_path_buf();96 97 if config.path_display == PathDisplay::Absolute {98 print!("{}", ls_colors.directory.paint(ROOT_DIR));12 unmodified lines111 let style =112 if component_path.symlink_metadata()113 .map(|md| md.file_type().is_symlink())114 .unwrap_or(false) {113- ls_colors.symlink115+ &ls_colors.symlink116 } else if component_path.is_dir() {115- ls_colors.directory117+ &ls_colors.directory118 } else if is_executable(&component_path) {117- ls_colors.executable119+ &ls_colors.executable120 } else {121 // Look up file name122 let o_style =123 component_path.file_name()124 .and_then(|n| n.to_str())125 .and_then(|n| ls_colors.filenames.get(n));126 127 match o_style {126- Some(s) => *s,128+ Some(s) => s,129 None =>130 // Look up file extension131 component_path.extension()132 .and_then(|e| e.to_str())133 .and_then(|e| ls_colors.extensions.get(e))132- .cloned()133- .unwrap_or_default()134+ .unwrap_or(&default_style)135 }136 };137 138 print!("{}", style.paint(comp_str));164 unmodified linesmodified:Cargo.lock+1 added-1 removed
1 [root]2 name = "fd"3-version = "1.0.0"3+version = "1.1.0"4 dependencies = [5 "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",6 "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",7 "ignore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",208 unmodified linesmodified:Cargo.toml+1 added-1 removed
123345674 unmodified lines[package]name = "fd"version = "1.0.0"version = "1.1.0"authors = ["David Peter <mail@david-peter.de>"]
[dependencies]ansi_term = "0.9"4 unmodified lines