From 61bdc4612ce50677f282243d03ecfc2a363196e2 Mon Sep 17 00:00:00 2001 From: Niklas Mohrin Date: Thu, 6 Aug 2026 01:31:39 +0200 Subject: [PATCH] Change Vec to slice --- src/config.rs | 10 +++++----- src/main.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/config.rs b/src/config.rs index feb5751..636c8f8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -746,7 +746,7 @@ impl ConfigLoader { fn read_internal( path: PathWithSource, allow_not_found: bool, - overrides: Vec, + overrides: &[String], ) -> Result { let read_raw_config = match fs::read_to_string(&path.path) { Ok(content) => toml::from_str(&content).with_context(|| { @@ -774,7 +774,7 @@ impl ConfigLoader { fn override_config_with( config_table: toml::Table, - overrides: Vec, + overrides: &[String], ) -> Result { let mut config_table = toml::Value::Table(config_table); for override_str in overrides { @@ -807,7 +807,7 @@ impl ConfigLoader { /// Create a loader that uses the config at `path`. /// `overrides`: If set, overrides the default values of the config - pub fn read(path: PathBuf, overrides: Vec) -> Result { + pub fn read(path: PathBuf, overrides: &[String]) -> Result { Self::read_internal( PathWithSource { path, @@ -821,7 +821,7 @@ impl ConfigLoader { /// Create a loader that uses the default config file location. If no file is present at the default location, the /// default configuration is used. /// `overrides`: If set, overrides the default values of the config - pub fn read_default_path(overrides: Vec) -> Result { + pub fn read_default_path(overrides: &[String]) -> Result { let path = get_default_config_path(); Self::read_internal(path, true, overrides) } @@ -1024,7 +1024,7 @@ mod test { #[test] fn change_value() { let original_config = base_config(); - let overrides = vec!["some.inner.value1 = 'some text'".to_string()]; + let overrides = &["some.inner.value1 = 'some text'".to_string()]; let new_config = ConfigLoader::override_config_with(original_config, overrides) .expect("config should be successfully overwritten"); diff --git a/src/main.rs b/src/main.rs index 641b956..f077c7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -202,9 +202,9 @@ fn try_main(args: Cli, enable_styles: bool) -> Result { // Look up config file, if none is found fall back to default config. debug!("Loading config"); let config_loader = match &args.config_path { - Some(path) if !args.seed_config => ConfigLoader::read(path.clone(), args.override_config) + Some(path) if !args.seed_config => ConfigLoader::read(path.clone(), &args.override_config) .context("Could not read config from given path")?, - _ => ConfigLoader::read_default_path(args.override_config) + _ => ConfigLoader::read_default_path(&args.override_config) .context("Could not read config from default path")?, }; let mut config = config_loader.load()?;