Skip to main content

parse_string

Function parse_string 

Source
pub fn parse_string<'a>(
    input: &str,
    base_dir: impl AsRef<Path>,
    parameters: impl Iterator<Item = &'a str>,
) -> Result<String, Error>
Expand description

Parses a file using the templating engine.

§Parameters

  • input: the contents to process
  • base_dir: all includes are resolved relative to this directory
  • parameters: if input contains any parameter macros, pass an iterator to them here. Otherwise pass std::iter::empty().

§Example

let res = parse_string(
    "#define A 4\nThe answer is A",
    std::env::current_dir().unwrap(),
    std::iter::empty()
).unwrap();
assert_eq!(res, "The answer is 4");