pub trait Env: Send + Sync {
// Required method
fn get(&self, key: &str) -> Option<String>;
// Provided method
fn has(&self, key: &str) -> bool { ... }
}Expand description
A read-only view of environment variables.
Implementations decide where the variables come from and whether they can
change: ProcessEnv reads the live process environment on every lookup,
while EnvList answers from a fixed list.
Required Methods§
Provided Methods§
Sourcefn has(&self, key: &str) -> bool
fn has(&self, key: &str) -> bool
Return whether a variable is present with a non-empty value.
Overriding this is only for taking a shortcut, not for changing the
answer: it must stay equivalent to
get(key).is_some_and(|v| !v.is_empty()).
§Parameters
key— variable name.
§Returns
true if key is present and its value is not empty.
§Errors and panics
This method does not fail or intentionally panic.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".