pub trait Substitute {
// Required methods
fn substitute(self, key: &str, value: &str) -> String;
fn substitute_all<'a>(
self,
substitutions: impl IntoIterator<Item = (&'a str, &'a str)>,
) -> String;
}Expand description
Extension trait for placeholder substitution on system prompt strings.
Provides simple {key} placeholder replacement after building a system prompt.
Unmatched placeholders are left as-is.
§Example
use llm_coding_tools_core::Substitute;
let text = "Available agents: {agents}".to_string();
let result = text
.substitute("agents", "code-review, research")
.substitute("missing", "ignored");
assert_eq!(result, "Available agents: code-review, research");Required Methods§
Sourcefn substitute(self, key: &str, value: &str) -> String
fn substitute(self, key: &str, value: &str) -> String
Replaces {key} placeholder with the given value.
Returns a new String with the substitution applied. If the placeholder is not found, returns the string unchanged.
Sourcefn substitute_all<'a>(
self,
substitutions: impl IntoIterator<Item = (&'a str, &'a str)>,
) -> String
fn substitute_all<'a>( self, substitutions: impl IntoIterator<Item = (&'a str, &'a str)>, ) -> String
Replaces multiple {key} placeholders with their values.
Accepts an iterator of (key, value) pairs.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.