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 <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-02-05 01:25:22 +01:00
parent 6b34e99b75
commit 01fa19aade

View file

@ -46,7 +46,7 @@ pub fn fetch_config(searchpath: &PathBuf) -> Result<Option<Value>> {
use libimagutil::variants::generate_variants as gen_vars; use libimagutil::variants::generate_variants as gen_vars;
use libimagerror::trace::trace_error; 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 modifier = |base: &PathBuf, v: &'static str| {
let mut base = base.clone(); let mut base = base.clone();
base.push(String::from(v)); base.push(String::from(v));
@ -55,13 +55,15 @@ pub fn fetch_config(searchpath: &PathBuf) -> Result<Option<Value>> {
let vals = vec![ let vals = vec![
vec![searchpath.clone()], 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)) env::var("HOME")
.unwrap_or(vec![]), .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)) xdg_basedir::get_data_home()
.unwrap_or(vec![]), .map(|data_dir| gen_vars(&data_dir, variants, &modifier))
.unwrap_or(vec![]),
]; ];
let config = Itertools::flatten(vals.iter()) let config = Itertools::flatten(vals.iter())