You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
README: add --print-layout / -p flag to both command synopses and usage examples.
CLAUDE.md: document the trait conventions for domain types (Display = ZMK,
qmk_name() for QMK, From<&str> for mixed-format parsing), note that ToZmk/ToQmk
were removed and must not be reintroduced, and add the cmp_owned allow exception
for KeyExpr's PartialEq impls.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+16-1Lines changed: 16 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,10 @@ examples/
44
44
45
45
All code must pass `cargo clippy --all-targets -- -W clippy::pedantic -D warnings` with no errors. This is enforced by CI. Run it locally before committing.
46
46
47
-
The one deliberate exception is `#[allow(clippy::implicit_hasher)]` on `parse_key_expr_str` — threading separate hasher type parameters through all private helpers adds noise without value for a CLI tool.
47
+
Deliberate exceptions:
48
+
49
+
-`#[allow(clippy::implicit_hasher)]` on `parse_key_expr_str` — threading separate hasher type parameters through all private helpers adds noise without value for a CLI tool.
50
+
-`#[allow(clippy::cmp_owned)]` on `KeyExpr`'s `PartialEq<&str>` / `PartialEq<str>` impls — the `Modified` variant (nested modifier expressions like `LG(LS(LBKT))`) must build a formatted string to compare; there is no allocation-free alternative.
48
51
49
52
## Testing
50
53
@@ -77,6 +80,18 @@ all of these are done and verified:
77
80
9. Report the pushed commit, pushed tag, GitHub Release workflow status, and
78
81
crates.io version.
79
82
83
+
## Trait conventions for domain types
84
+
85
+
The typed domain types in `src/codes.rs` (`KeyCode`, `Modifier`, `KeyExpr`, `RgbAction`, `MouseMovement`, `MouseButton`, `MouseScroll`, `ModPrefix`) follow a consistent pattern:
86
+
87
+
-**`Display`** outputs the **ZMK** spelling. This is the canonical string form; use `.to_string()` or format interpolation `{x}` wherever a ZMK string is needed.
88
+
-**`qmk_name()` / `qmk_mod_name()`** methods return the **QMK** spelling as `&str`. Call these directly in QMK renderers; do not add a trait wrapper.
89
+
-`Modifier` exposes three QMK spellings: `qmk_mod_name()` (`MOD_LSFT`, used in `MT`/`OSM`), `qmk_fn_name()` (`LSFT`, used in modifier-wrapping functions), and `zmk_name()` via `Display`.
90
+
-`KeyExpr` has a `to_qmk() -> String` method for the recursive modifier-expression case (e.g. `LGUI(LSFT(KC_LBRC))`).
91
+
-**`From<&str>` / `From<String>`** are implemented for types with an `Unknown` fallback variant. They try ZMK spelling first, then QMK, then fall back to `Unknown(raw)`. Use these when the source format is ambiguous or mixed.
92
+
-**`from_qmk(s)` / `from_zmk(s)`** associated functions return `Option<Self>` for strict format-specific parsing (no `Unknown` fallback). Prefer these in parsers where the input format is known.
93
+
- There are **no custom `ToZmk` or `ToQmk` traits**. Earlier versions had them; they were removed because `Display` already covers the ZMK case and the QMK case has no stdlib equivalent. Don't reintroduce them.
94
+
80
95
## Key mapping conventions
81
96
82
97
QMK and ZMK use different names for the same physical keys. The canonical mapping lives in `src/codes.rs`. Notable differences:
0 commit comments