diff --git a/lib/core/libimagrt/src/configuration.rs b/lib/core/libimagrt/src/configuration.rs index 20892064..0706935a 100644 --- a/lib/core/libimagrt/src/configuration.rs +++ b/lib/core/libimagrt/src/configuration.rs @@ -56,12 +56,12 @@ pub fn fetch_config(searchpath: &PathBuf) -> Result { vec![ vec![searchpath.clone()], - gen_vars(searchpath.clone(), variants.clone(), &modifier), + gen_vars(searchpath, variants.clone(), &modifier), - env::var("HOME").map(|home| gen_vars(PathBuf::from(home), variants.clone(), &modifier)) + env::var("HOME").map(|home| gen_vars(&PathBuf::from(home), variants.clone(), &modifier)) .unwrap_or(vec![]), - xdg_basedir::get_data_home().map(|data_dir| gen_vars(data_dir, variants.clone(), &modifier)) + xdg_basedir::get_data_home().map(|data_dir| gen_vars(&data_dir, variants.clone(), &modifier)) .unwrap_or(vec![]), ].iter() .flatten() diff --git a/lib/etc/libimagutil/src/variants.rs b/lib/etc/libimagutil/src/variants.rs index ac56eaeb..0a456de9 100644 --- a/lib/etc/libimagutil/src/variants.rs +++ b/lib/etc/libimagutil/src/variants.rs @@ -32,12 +32,12 @@ * ``` * */ -pub fn generate_variants(base: A, modders: Vec, f: &F) +pub fn generate_variants(base: &A, modders: Vec, f: &F) -> Vec where F: Fn(&A, B) -> C { - modders.into_iter().map(|m| f(&base, m)).collect() + modders.into_iter().map(|m| f(base, m)).collect() } #[cfg(test)] @@ -49,7 +49,7 @@ mod test { fn test_variants_simple() { let base = 1; let vars = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - let res = generate_variants(base, vars, &|base, var| base + var); + let res = generate_variants(&base, vars, &|base, var| base + var); assert!(res.len() == 11, format!("Length is {} instead of 11", res.len())); assert!(res.iter().all(|i| *i > 0)); @@ -62,7 +62,7 @@ mod test { let base = PathBuf::from("/"); let vars = vec!["foo", "bar", "baz"]; - let res = generate_variants(base, vars, &|base, var| { + let res = generate_variants(&base, vars, &|base, var| { let mut base = base.clone(); base.push(var); base