mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-29 14:21:24 -03:00
There are many places where we want to treat a missing variable the same as a variable with an empty value. In C++ we handle this by branching on maybe_t<env_var_t>::missing_or_empty(). If it returns false, we go on to access maybe_t<env_var_t>::value() aka operator*. In Rust, Environment::get() will return an Option<EnvVar>. We could define a MissingOrEmpty trait and implement it for Option<EnvVar>. However that will still leave us with ugly calls to Option::unwrap() (by convention Rust does use shorthands like *). Let's add a variable getter that returns none for empty variables.
9.1 KiB
9.1 KiB