[][src]Struct markings::Opts

pub struct Opts { /* fields omitted */ }

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.