From b3fe8faabaf013d34f6c59a23db381bee9962991 Mon Sep 17 00:00:00 2001 From: alemi Date: Fri, 25 Oct 2024 17:30:02 +0200 Subject: [PATCH] fix: trait replace vars uses pre-parsed map --- src/ext.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ext.rs b/src/ext.rs index dca3c80..c445f4b 100644 --- a/src/ext.rs +++ b/src/ext.rs @@ -1,6 +1,4 @@ -use std::sync::OnceLock; - -use crate::PostWomanError; +use std::{collections::HashMap, sync::OnceLock}; #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[serde(untagged)] @@ -55,7 +53,7 @@ pub struct FillError(pub String); pub trait FillableFromEnvironment: Sized { fn fill(self, env: &toml::Table) -> Result; - fn replace(mut from: String, env: &toml::Table) -> Result { + fn replace(mut from: String, env: &HashMap) -> Result { let placeholders: Vec<(String, String)> = var_matcher() .captures_iter(&from) .map(|m| m.extract()) @@ -67,7 +65,7 @@ pub trait FillableFromEnvironment: Sized { for (txt, var) in placeholders { let value = env.get(&var).ok_or(FillError(var.to_string()))?; - from = from.replace(&txt, &stringify_toml(value)); + from = from.replace(&txt, value); } Ok(from)