pub struct Opts { /* private fields */ }
Expand description
Opts
are a set of options to configure how a template will be parsed and applied
§The default options would fail if
- there is an empty template (e.g. no replacement keys)
- there are duplicate keys
- apply will fail if the exact keys aren’t applied
§default options
let input = "this is a ${name}.";
let template = Template::parse(&input, Opts::default()).unwrap();
§various options
// this will allow these options in the parsing/application
let opts = Opts::default()
.optional_keys() // optional keys -- args aren't required to match the template keys
.duplicate_keys() // duplicate keys -- duplicate keys in the template will use the same argument
.empty_template() // templates can just be strings that act as an "identity"
.build();
let input = "this is a ${name}.";
let template = Template::parse(&input, opts).unwrap();
Implementations§
Source§impl Opts
impl Opts
Sourcepub fn optional_keys(&mut self) -> &mut Self
pub fn optional_keys(&mut self) -> &mut Self
Allow optional keys
Keys found in the template application don’t have to appear in the template
Sourcepub fn duplicate_keys(&mut self) -> &mut Self
pub fn duplicate_keys(&mut self) -> &mut Self
Allow duplicate keys
Multiple keys in the template will be replaced by the same argument
Sourcepub fn empty_template(&mut self) -> &mut Self
pub fn empty_template(&mut self) -> &mut Self
Allows for an empty template – e.g. a template without any args
When args are applied to this, the original string is returned
Trait Implementations§
impl Copy for Opts
impl StructuralPartialEq for Opts
Auto Trait Implementations§
impl Freeze for Opts
impl RefUnwindSafe for Opts
impl Send for Opts
impl Sync for Opts
impl Unpin for Opts
impl UnwindSafe for Opts
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more