Filler

Trait Filler 

Source
pub trait Filler<W, E>
where W: Write,
{ // Required method fn fill(&mut self, output: &mut W, key: &str) -> Result<(), E>; }
Expand description

Implementers of this trait have the ability to fill template strings.

It is extremely strongly recommended that fillers only push to the output, and do not perform any other modifications of it.

I mean, if you implement Filler<String, _>, you get a &mut String and it’s possible to do other things with it, but that’s a terrible idea. I’m almost ashamed of ideas like making {␡} pop the last character, and {←rot13} ROT-13-encode what precedes it in the string.

Required Methods§

Source

fn fill(&mut self, output: &mut W, key: &str) -> Result<(), E>

Fill the value for the given key into the output string.

Implementations on Foreign Types§

Source§

impl<K, V, W> Filler<W, SimpleFillerError> for &BTreeMap<K, V>
where K: Borrow<str> + Ord, V: AsRef<str>, W: Write,

Available on crate feature alloc only.
Source§

fn fill(&mut self, output: &mut W, key: &str) -> Result<(), SimpleFillerError>

Source§

impl<K, V, W> Filler<W, SimpleFillerError> for &HashMap<K, V>
where K: Borrow<str> + Eq + Hash, V: AsRef<str>, W: Write,

Available on crate feature std only.
Source§

fn fill(&mut self, output: &mut W, key: &str) -> Result<(), SimpleFillerError>

Implementors§

Source§

impl<F, W, E> Filler<W, E> for F
where F: FnMut(&mut W, &str) -> Result<(), E>, W: Write,