pub trait EnvKey {
// Required method
fn key() -> &'static str;
}Expand description
EnvKey is a trait that represents the environment key.
§Example
use env_type::types::{EnvType, EnvKey};
use std::str::FromStr;
struct NewEnvKey;
impl EnvKey for NewEnvKey {
fn key() -> &'static str {
"NEW_ENV"
}
}
std::env::set_var("NEW_ENV", "Production");
let env = EnvType::from_env_key::<NewEnvKey>();
assert_eq!(EnvType::Prod, env);Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.