[−][src]Struct markings::Opts
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();
Methods
impl Opts
[src]
pub fn optional_keys(&mut self) -> &mut Self
[src]
Allow optional keys
Keys found in the template application don't have to appear in the template
pub fn duplicate_keys(&mut self) -> &mut Self
[src]
Allow duplicate keys
Multiple keys in the template will be replaced by the same argument
pub fn empty_template(&mut self) -> &mut Self
[src]
Allows for an empty template -- e.g. a template without any args
When args are applied to this, the original string is returned
pub fn build(self) -> Self
[src]
Construct the option set
Trait Implementations
impl Clone for Opts
[src]
impl Copy for Opts
[src]
impl Debug for Opts
[src]
impl Default for Opts
[src]
impl PartialEq<Opts> for Opts
[src]
impl StructuralPartialEq for Opts
[src]
Auto Trait Implementations
impl RefUnwindSafe for Opts
impl Send for Opts
impl Sync for Opts
impl Unpin for Opts
impl UnwindSafe for Opts
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,