[][src]Struct test_common::system::env::TemporalEnvironmentVariable

pub struct TemporalEnvironmentVariable {
    pub name: String,
    pub current_value: String,
    // some fields omitted
}

Context manager like struct to create an environment variable to perform test with it.

If environment variable already existed then former value is stored before setting the new one. Former value is restored when this type falls out of scope.

Example

use test_common::system::env::TemporalEnvironmentVariable;

{
    let test_env = TemporalEnvironmentVariable::new("ENVTEST", "test_value");
    // Do your operations with environment variable.
} // Here test environment variable is set to former value if any..

Fields

name: Stringcurrent_value: String

Methods

impl TemporalEnvironmentVariable[src]

pub fn new<T, U>(name: T, value: U) -> Self where
    T: AsRef<str> + AsRef<OsStr>,
    U: AsRef<str>, 
[src]

Create a TemporalEnvironmentVariable instance with given name and value.

If an env var with the same name already exists, previous value is stored at old_value attribute. That old_value is restored as env var value when this instance is dropped.

pub fn set_var<T>(&mut self, new_value: T) where
    T: AsRef<str>, 
[src]

Set a new current value for env var.

Parameters:

  • new_value: New value to store.

Trait Implementations

impl Drop for TemporalEnvironmentVariable[src]

fn drop(&mut self)[src]

Leave environment variable with value it had before, if any.

Auto Trait Implementations

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, 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<V, T> VZip<V> for T where
    V: MultiLane<T>,