rust-cli / confy

🛋 Zero-boilerplate configuration management in Rust
Other
896 stars 59 forks source link

Call default() only once on load #35

Closed 1uka closed 3 years ago

1uka commented 3 years ago

Currently when calling confy::load or confy::load_path, inside the load_path function the configuration struct's default method is called twice. This may be unwanted for some reasons:

I agree that the Default trait maybe shouldn't bother with such cases, but anyhow it seems unnecessary to call default() twice.

This pull request introduces a minor change, i.e. in the load_path function a local variable is set by calling default() once, then a reference is passed to the store() function and the variable is returned to the caller.