option_env! is great and all but it can’t be used inside of macros that take literals.
default_env! tries to solve this and seems generally useful enough that it could be included alongside
std::*env!. Is there any reason why this wasn’t already the case?
In general, the answer to “why is x not in
std?” is “because it does not have to be.”
default_env behavior is somewhat niche – I rarely want a surprise empty string when an environment variable isn’t set – and it is clearly implementable in a crate (since you linked to it), so it doesn’t seem like an obvious candidate for
std to me.
std, then? Because we didn’t have proc macros originally, and those are necessary to implement it in a crate.)
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.