From 2b47460258b7fee05f8f674f5eaffddbb4a07b1f Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Sat, 19 Jul 2025 20:52:37 -0500 Subject: [PATCH] "Merge" method on PartialConfig I'm going to roll the partial configurations together to get the most complete version that I can. Add a function to make that easier. --- src/config.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/config.rs b/src/config.rs index 1f611aa..99f6071 100644 --- a/src/config.rs +++ b/src/config.rs @@ -47,6 +47,19 @@ impl PartialConfig { ..self } } + + // Merges two `PartialConfig`'s together, producing a new one. + // Non-None values on the right-hand side are used to replace values + // in the left-hand side, even if they are Some(_). + fn merge(self, other: Self) -> Self { + Self { + project_path: other.project_path.or(self.project_path), + gitea_url: other.gitea_url.or(self.gitea_url), + owner: other.owner.or(self.owner), + repo: other.repo.or(self.repo), + token: other.token.or(self.token), + } + } } impl TryFrom<&Table> for PartialConfig {