Context

Trait Context 

Source
pub trait Context {
    // Required method
    fn get(&self, key: &str) -> Option<String>;
}
Expand description

A trait for providing values for variable expansion.

This allows format_with to be generic over the source of the variables, making it easy to test with a HashMap or use with environment variables.

Required Methods§

Source

fn get(&self, key: &str) -> Option<String>

Retrieves a value for a given key.

§Parameters
  • key: The name of the variable to look up.
§Returns
  • Some(String) if the key exists.
  • None if the key does not exist.

Implementations on Foreign Types§

Source§

impl<K, S> Context for HashMap<K, S>
where K: Borrow<str> + Eq + Hash, S: AsRef<str>,

Source§

fn get(&self, key: &str) -> Option<String>

Implementors§