Skip to content

Fix ignored variant requires Default trait#39

Merged
rezigned merged 4 commits intomainfrom
fix-defaul-trait
Apr 25, 2026
Merged

Fix ignored variant requires Default trait#39
rezigned merged 4 commits intomainfrom
fix-defaul-trait

Conversation

@rezigned
Copy link
Copy Markdown
Owner

@rezigned rezigned commented Apr 14, 2026

Ignored variants like the following code shouldn't require a Default trait implementation.

The Default trait was introduced in v1.0.0-rc3, which allows users to capture default values into Named and Unnamed variants. However, it doesn't respect the ignore field. Thus, any code that uses the ignore field requires the Default trait to be implemented (undesired behavior).

#[derive(Debug, PartialEq, Eq, keymap_derive::KeyMap, Clone)]
enum Foo {
    /// Active variant
    #[key("a")]
    Bar,
    /// Ignored variant (should NOT require `Default` trait)
    #[key(ignore)]
    Baz(Baz),
}

Ignored variants no longer need the Default trait implemented, even when they have fields.
Previously, the macro generated Default::default() for all variants in deserialization
code, causing compile errors for ignored variants without Default.
Previously used ::keymap_parser which fails when keymap is not the root crate.
Now uses keymap_parser (without ::) which resolves correctly.
@rezigned rezigned force-pushed the fix-defaul-trait branch 2 times, most recently from bb571ab to a4cc162 Compare April 18, 2026 14:47
…nding

Add support for u8, u16, u32, u64, and usize field types when using
@Digit key group. The character from key event is automatically converted
to its numeric digit value and cast to the target type.
@rezigned rezigned merged commit 3a831c1 into main Apr 25, 2026
4 checks passed
@rezigned rezigned deleted the fix-defaul-trait branch April 25, 2026 07:48
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

Successfully merging this pull request may close these issues.

1 participant