Skip to content
Myr

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

3 files+9 added−8 removed

modified:src/main.rs+7 added-6 removed
88 unmodified lines
89 #[cfg(not(target_family = "unix"))]90 let is_executable = |p: &std::path::PathBuf| {false};9192 if let Some(ref ls_colors) = config.ls_colors {93 let default_style = ansi_term::Style::default();9495 let mut component_path = base.to_path_buf();9697 if config.path_display == PathDisplay::Absolute {98 print!("{}", ls_colors.directory.paint(ROOT_DIR));
12 unmodified lines
111 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));126127 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 };137138 print!("{}", style.paint(comp_str));
164 unmodified lines
modified:Cargo.lock+1 added-1 removed
1[root]2name = "fd"3version = "1.0.0"3version = "1.1.0"4dependencies = [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 lines
modified:Cargo.toml+1 added-1 removed