From 01fa19aadebbe94c6b759608e2f75f2714b74c94 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Feb 2019 01:25:22 +0100 Subject: [PATCH] Remove clone() calls We should be able, from the signature of the `generate_variants()` helper function, to pass a `Vec<&T>` here, so cloning should not be necessary. Signed-off-by: Matthias Beyer --- lib/core/libimagrt/src/configuration.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/core/libimagrt/src/configuration.rs b/lib/core/libimagrt/src/configuration.rs index eb5bf21b..65353b2f 100644 --- a/lib/core/libimagrt/src/configuration.rs +++ b/lib/core/libimagrt/src/configuration.rs @@ -46,7 +46,7 @@ pub fn fetch_config(searchpath: &PathBuf) -> Result> { use libimagutil::variants::generate_variants as gen_vars; use libimagerror::trace::trace_error; - let variants = vec!["config", "config.toml", "imagrc", "imagrc.toml"]; + let variants : Vec<&'static str> = vec!["config", "config.toml", "imagrc", "imagrc.toml"]; let modifier = |base: &PathBuf, v: &'static str| { let mut base = base.clone(); base.push(String::from(v)); @@ -55,13 +55,15 @@ pub fn fetch_config(searchpath: &PathBuf) -> Result> { let vals = vec![ vec![searchpath.clone()], - gen_vars(searchpath, variants.clone(), &modifier), + gen_vars(searchpath, variants, &modifier), - env::var("HOME").map(|home| gen_vars(&PathBuf::from(home), variants.clone(), &modifier)) - .unwrap_or(vec![]), + env::var("HOME") + .map(|home| gen_vars(&PathBuf::from(home), variants, &modifier)) + .unwrap_or(vec![]), - xdg_basedir::get_data_home().map(|data_dir| gen_vars(&data_dir, variants.clone(), &modifier)) - .unwrap_or(vec![]), + xdg_basedir::get_data_home() + .map(|data_dir| gen_vars(&data_dir, variants, &modifier)) + .unwrap_or(vec![]), ]; let config = Itertools::flatten(vals.iter())