[][src]Struct winnow_sm::Env

pub struct Env(HashMap<String, String>);

User-defined variables

Methods

impl Env[src]

pub fn get_variable(&self, variable_name: &str) -> String[src]

Retrieve the value stored at variable_name.

pub fn set_variable(&mut self, variable_name: &str, value: String)[src]

Set variable_name to value, always overwrites

pub fn resolve_template(&self, template: &str) -> String[src]

Resolve a string template

Example

env.set_variable("NAME", "Al Gore".into());
env.set_variable("COLOR", "Green".into());
let template = "Hi there, $NAME, seen anything $COLOR lately?";
let expected = "Hi there, Al Gore, seen anything Green lately?";

If variable is not set, variable name will be used:

let template = "Hi there, $NAME, how is $TOPIC?";
let expected = "Hi there, Al Gore, how is TOPIC?";

Trait Implementations

impl Default for Env[src]

impl PartialEq<Env> for Env[src]

impl Debug for Env[src]

Auto Trait Implementations

impl Send for Env

impl Unpin for Env

impl Sync for Env

impl UnwindSafe for Env

impl RefUnwindSafe for Env

Blanket Implementations

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

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

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.

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

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]