struct_string_template/
builder.rs1use crate::templater::Templater;
2
3pub struct TemplaterBuilder<T> {
4 t: Templater<T>,
5}
6
7impl<T> TemplaterBuilder<T> {
8 pub fn new() -> Self {
9 Self { t: Templater::new() }
10 }
11
12 pub fn with_selector<S, F>(mut self, selector: S, accessor: F) -> Self
13 where
14 S: Into<String>,
15 F: Fn(&T) -> Option<String> + 'static + Send + Sync
16 {
17 self.t.insert(selector.into(), Box::new(accessor));
18 self
19 }
20
21 pub fn build(self) -> Templater<T> {
22 self.t
23 }
24}