Function varsun::mswin::substitute
[−]
[src]
pub fn substitute<F>(src: &str, mapfn: F) -> String where F: Fn(&str) -> Option<String>
Parse src and substitute found variables with result of mapfn
.
Examples
use varsun::mswin::substitute; let src = "foo is %foo%."; let res = substitute(src, |name: &str| -> Option<String> { match name { "foo" => Some("FOO!!".to_string()), _ => None, // If None returns, variable replaces with "" (empty string). } });