From e8b21c5ce01c8bf68f64109983b520a7984d88c7 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sun, 1 Jan 2023 16:54:10 -0800 Subject: [PATCH] Change `with_toml_strings` to `incorporate_toml_string` It makes more sense for this function to change `self`. --- lib/src/settings.rs | 15 ++++++--------- src/cli_util.rs | 3 ++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/src/settings.rs b/lib/src/settings.rs index ffa170d7f..e2f3862a7 100644 --- a/lib/src/settings.rs +++ b/lib/src/settings.rs @@ -45,21 +45,18 @@ impl UserSettings { UserSettings { config, timestamp } } - pub fn with_toml_strings( - &self, + pub fn incorporate_toml_strings( + &mut self, toml_strs: &[String], - ) -> Result { + ) -> Result<(), config::ConfigError> { let mut config_builder = config::Config::builder().add_source(self.config.clone()); for s in toml_strs { config_builder = config_builder.add_source(config::File::from_str(s, config::FileFormat::Toml)); } - let new_config = config_builder.build()?; - let timestamp = get_timestamp_config(&new_config, "user.timestamp"); - Ok(UserSettings { - config: new_config, - timestamp, - }) + self.config = config_builder.build()?; + self.timestamp = get_timestamp_config(&self.config, "user.timestamp"); + Ok(()) } pub fn with_repo(&self, repo_path: &Path) -> Result { diff --git a/src/cli_util.rs b/src/cli_util.rs index c6246998e..6d271a932 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -1590,7 +1590,8 @@ fn handle_early_args( ui.set_pagination(crate::ui::PaginationChoice::No); } if !args.config_toml.is_empty() { - let settings = ui.settings().with_toml_strings(&args.config_toml)?; + let mut settings = ui.settings().clone(); + settings.incorporate_toml_strings(&args.config_toml)?; ui.reset(settings); } Ok(())