Function varsun::posix::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::posix::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). } });