refactor(hm-config): Mark public config structs #[non_exhaustive]#120
Merged
markovejnovic merged 1 commit intoJun 10, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Smell
Config,CloudConfig, andPreferencesincrates/hm-config/src/lib.rsare public structs with all-public fields and no#[non_exhaustive]. They are designed to grow over time (config knobs), but every new field is a breaking change for any external struct-literal constructor, and downstream code can build partially-validated configs by hand, bypassing the centralizedDefault/load_from_pathsconstruction path.Change
#[non_exhaustive]toConfig,CloudConfig, andPreferences.save_and_reload_roundtriptest to construct via..Default::default()/..CloudConfig::default()instead of fully-enumerated struct literals, so construction funnels throughDefault(where defaults and future invariants live). Other internalDefaultimpls already centralize field initialization.This is behavior-preserving: serde derives, defaults, and load/save logic are unchanged.
Type-safety pattern
This applies the
#[non_exhaustive]on public config structs pattern (as used in diesel). Marking these structs non-exhaustive makes adding a field a non-breaking change for downstream crates and forces external construction throughDefault/load, centralizing default values and any future validation invariants. External crates can no longer build partially-valid configs by hand.CI
Full CI runs on this PR. Locally only
cargo check -p hm-config(andcargo test -p hm-config, all green) was run per the scope of this change; the full workspace/TS build was not run locally.