Skip to main content

Env

Trait Env 

Source
trait Env {
    // Required method
    fn get(&self, name: &'static str) -> Result<String, VarError>;
}
Expand description

A thin wrapper around env::Vars to allows dummy implementations for unit testing. Code that deals with env::Vars is often hard to test, since altering env vars in a test may affect other tests that are running concurrently. This trait can easily be implemented for a std::collections::HashMap, thus keeping updates locally.

Required Methods§

Source

fn get(&self, name: &'static str) -> Result<String, VarError>

Fetches the value of a given environment variable. Returns an error if no such variable is present.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Env for Vars

Source§

fn get(&self, name: &'static str) -> Result<String, VarError>

Implementors§