Skip to content

Drop Default supertrait from Settings#218

Draft
TheJokr wants to merge 1 commit into
mainfrom
lblocher/settings-no-default
Draft

Drop Default supertrait from Settings#218
TheJokr wants to merge 1 commit into
mainfrom
lblocher/settings-no-default

Conversation

@TheJokr

@TheJokr TheJokr commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

This allows types without a sensible default value to implement Settings. Top-level setting types used with Cli still need to implement Default for the --generate option, but individual fields can now use types like NonZeroUsize or SystemTime. The #[settings] proc-macro still generates a serde-based Default impl. If a field does not have a Default impl, use #[settings(impl_default = false)] or specify a field-specific Default with the #[serde(default = ...)] field attribute.

This is a breaking change: a function taking a T: Settings and calling T::default() was valid before, and is not anymore. However, this is the only breakage this change can cause.

Removing the Default supertrait also allows us to clean up the compatibility hack from foundations#150.

@TheJokr TheJokr self-assigned this Jun 19, 2026
This allows types without a sensible default value to implement
`Settings`. Top-level setting types used with `Cli` still need to
implement Default for the `--generate` option, but individual fields can
now use types like `NonZeroUsize` or `SystemTime`. The `#[settings]`
proc-macro still generates a serde-based Default impl. If a field
does not have a Default impl, use `#[settings(impl_default = false)]` or
specify a _field-specific_ Default with the `#[serde(default = ...)]`
field attribute.

This is a breaking change: a function taking a `T: Settings` and calling
`T::default()` was valid before, and is not anymore. However, this is
the only breakage this change can cause.

Removing the Default supertrait also allows us to clean up the
compatibility hack from foundations#150.
@TheJokr TheJokr force-pushed the lblocher/settings-no-default branch from 3f178b6 to ee8432d Compare June 19, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant