Skip to content

feat: improve Gotcha builder API syntax#19

Merged
Kilerd merged 1 commit intomainfrom
improve-gotcha-api-syntax
Feb 4, 2026
Merged

feat: improve Gotcha builder API syntax#19
Kilerd merged 1 commit intomainfrom
improve-gotcha-api-syntax

Conversation

@Kilerd
Copy link
Copy Markdown
Owner

@Kilerd Kilerd commented Feb 4, 2026

Remove the awkward <(), ()> type syntax requirement when creating Gotcha instances with custom types.

Previously, creating a Gotcha instance with custom state and config required specifying dummy type parameters: Gotcha::<(), ()>::with_types::<AppState, AppConfig>(). This change improves the API by moving type construction methods to a non-generic impl block, allowing cleaner syntax: Gotcha::with_types::<AppState, AppConfig>(), plus convenience methods with_state() and with_config() for single-type scenarios.

Added comprehensive tests and examples demonstrating the new API patterns. All existing code continues to work unchanged.

🧪 Generated with Claude Code

Previously, creating a Gotcha instance with custom types required the awkward syntax:
  Gotcha::<(), ()>::with_types::<AppState, AppConfig>()

This commit improves the API by moving type construction methods to a non-generic impl block, allowing for cleaner syntax:
  Gotcha::with_types::<AppState, AppConfig>()
  Gotcha::with_state::<AppState>()
  Gotcha::with_config::<AppConfig>()

Benefits:
- No more confusing <(), ()> type parameters
- Cleaner, more intuitive API
- Better developer experience
- Maintains backward compatibility

Added comprehensive tests and examples demonstrating the new API.
@Kilerd Kilerd merged commit 68f903a into main Feb 4, 2026
65 of 71 checks passed
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