Skip to content

Conversation

oguzkocer
Copy link
Contributor

Summary

Refactor WordPress content ID types to use macros, eliminating duplication across PostId, MediaId, CommentId, CategoryId, TagId, PostRevisionId, and UserId.

Changes

  • Add wp_content_i64_id! and wp_content_string_id! macros with fully-qualified types
  • Replace ~17 lines of boilerplate per ID type with single macro call
  • Add From<T> trait implementations as enhancement
  • Export macros in prelude for easy access

@oguzkocer oguzkocer added this to the 0.2 milestone Sep 3, 2025
@oguzkocer oguzkocer added the Rust label Sep 3, 2025
Introduces wp_content_i64_id and wp_content_string_id macros to eliminate
duplication across ID type implementations. This refactor reduces boilerplate
code while maintaining identical functionality and type safety.

Changes:
- Add wp_content_macros.rs with fully-qualified type macros
- Refactor PostId, MediaId, CommentId, CategoryId, TagId, PostRevisionId, UserId to use wp_content_i64_id!
- Export macros in prelude for easy access
- Remove duplicate implementations (17 lines per ID type → 1 line)
- Add From<T> trait implementations as enhancement
- Maintain exact same generated code and behavior
@oguzkocer oguzkocer force-pushed the refactor/wp-content-id-macros branch from 7f8d0be to e23344c Compare September 3, 2025 14:49
@oguzkocer oguzkocer marked this pull request as ready for review September 3, 2025 16:38
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