Replace derive_more event helpers with a local macro - #1113
Open
joshka wants to merge 1 commit into
Open
Conversation
Generate event enum `is_*` helpers locally so crossterm avoids the derive_more proc-macro dependency while preserving the existing API.
joshka
force-pushed
the
joshka/replace-derive-more-event-macro
branch
from
August 20, 2026 22:44
140fc89 to
b712845
Compare
joshka
marked this pull request as ready for review
August 21, 2026 17:15
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.
Summary
This removes the
derive_moredependency and feature used to provide the event enumis_*methods.The public methods and their behavior remain unchanged. They are now generated by a small private
macro_rules!macro, while payload-sensitive predicates remain handwritten.This follows the direction discussed in PR #949, where the tradeoff between boilerplate and an additional proc-macro dependency was discussed. PR #970 subsequently made the dependency optional, but it was still enabled by default.
Why
The generated methods are all simple variant checks, so requiring downstream users to compile
derive_moreand its proc-macro dependencies is disproportionate to the behavior being added.The local macro keeps the declarations concise and consistent:
The variants previously marked
is_variant(ignore)—KeyCode::F,Char,Media, andModifier—are intentionally omitted from the macro. They already have handwritten payload-aware methods:is_function_key,is_char,is_media_key, andis_modifier. This avoids duplicate or conflicting methods while preserving their value-sensitive behavior.Compile-time comparison
These were clean, isolated builds on the same machine and toolchain:
derive_morecargo buildcargo checkThe
derive_morebuild additionally compiled proc-macro dependencies includingsyn,quote,convert_case,derive_more-impl, andderive_more.For context, PR #949 measured the original fresh-project comparison at 1.851s versus 3.539s, and a clean M2 crate build at 2.016s versus 2.688s. Exact timings vary by toolchain and machine, but the direction is consistent.
Validation
cargo fmt --checkcargo test --all-targets --lockedcargo test --no-default-features --all-targets --lockedcargo test --all-features --all-targets --lockedcargo clippy --all-targets --all-features --locked -- -D warningscargo doc --no-deps --all-features --lockedcc @archseer @the-mikedavis