this post was submitted on 11 Sep 2025
5 points (100.0% liked)

Rust

7572 readers
2 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 2 years ago
MODERATORS
 

This crate contains a macro for generating a struct which reads the environmental variables defined in the configured file.

This allows to have a single point of definition for the env configuration, thus avoiding a possible incoherence between the documentation and the implementation.

GitHub link: https://github.com/asperan/declarative-env

Note: I'm the developer of this crate, I'm sharing this hoping that it could help someone

top 2 comments
sorted by: hot top controversial new old
[–] anton@lemmy.blahaj.zone 2 points 3 months ago (1 children)

If the spec contains default values why not make a constructor with all the missing fields or implement Default when all fields are covered?

Also lol:

#[test]
fn test_config_load() {
    todo!();
}
[–] asperan@programming.dev 2 points 3 months ago

If the spec contains default values why not make a constructor with all the missing fields or implement Default when all fields are covered?

For the first implementation I wanted to keep it simple, I don't exclude that in the future it will change.

Also lol:

Yep, I still need to figure out deep macro testing, for now I use the integration tests and cargo expand. This will absolutely change in the future :)

Thanks for the feedback!