replacer 0.4.0

Creating compilable Rust source code templates.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use pretty_assertions::assert_eq;

use replacer::{rule::StringRule, TemplateBuilder};

const STRING_TEMPLATE: &str = include_str!("string_template.rs");
const STRING_RESULT: &str = include_str!("string_result.rs");

#[test]
fn test_string() {
    let template = TemplateBuilder::new()
        .rule(StringRule::new("replace_with_world", "world").unwrap())
        .build();

    assert_eq!(template.apply(STRING_TEMPLATE).unwrap(), STRING_RESULT);
}