Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to Env when variables missing some key #20

Open
futurist opened this issue Jun 5, 2024 · 1 comment
Open

Fallback to Env when variables missing some key #20

futurist opened this issue Jun 5, 2024 · 1 comment

Comments

@futurist
Copy link

futurist commented Jun 5, 2024

Like below:

match (&value, &variable.default) {
				(None, None) => {
					// --- here also .get from Env for the key/value as fallback
					return Err(error::NoSuchVariable {
						position: variable.name_start,
						name: variable.name.to_owned(),
					}
					.into());
				},
}
@de-vri-es
Copy link
Contributor

This is currently already possible if you create a custom VariableMap and implement this logic there.

Or, you could simple create a map, fill it with entries from std::env::vars() and then insert other variables.

It would be possible to add combinators to variable maps, a bit like the combinators for iterators in the standard library. But I'm not sure if it would really be worth the added complexity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants