1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use crateprint_formatted_error;
/// Retrieves the value of an environment variable by its name and returns it.
///
/// This function attempts to retrieve the value of an environment variable specified by
/// `env_var_name`. If the variable exists and has a value, that value is returned as a `String`.
/// If the variable is not set or there is an error while retrieving it, an error message is
/// printed to the standard error (stderr) stream, and the program exits with a status code of 1.
///
/// # Arguments
///
/// * `env_var_name` - The name of the environment variable to retrieve.
///
/// # Returns
///
/// The value of the specified environment variable as a `String`.
///
/// # Panics
///
/// This function will panic and terminate the program if the specified environment variable is
/// not set or if there is an error while retrieving it.
///
/// # Examples
///
/// ```
/// let my_var = env_var("MY_VARIABLE");
/// println!("Value of MY_VARIABLE: {}", my_var);
/// ```
///