Skip to content

Conversation

konard
Copy link
Member

@konard konard commented Sep 11, 2025

Summary

This PR implements the changes requested in issue #5 to use associated types instead of generic parameters for the Doublets trait, making the API more idiomatic.

Changes Made

  • Updated Links trait: Links<T: LinkType>Links with type Item: LinkType
  • Updated Doublets trait: Doublets<T: LinkType>: Links<T>Doublets: Links (inherits Item from Links)
  • Updated DoubletsExt trait: DoubletsExt<T: LinkType>: Sized + Doublets<T>DoubletsExt: Sized + Doublets
  • Updated all trait implementations in Store and Unit Store to use associated types
  • Updated decorator structs to use the new trait syntax
  • Updated all usage sites across the codebase, tests, and FFI bindings

Benefits

This change enables cleaner, more idiomatic code as shown in the issue example:

Before:

struct Wrapper<T, D: Doublets<T>> {
    doublets: D,
    _marker: PhantomData<T>,
}

After:

struct Wrapper<D: Doublets> {
    doublets: D,
}
// `T` is now `D::Item`

Compatibility

This is a breaking change that affects:

  • All implementations of Links, Doublets, and DoubletsExt traits
  • Any code using these traits with generic parameters
  • FFI bindings and dynamic trait objects

Test plan

  • Updated all trait definitions to use associated types
  • Updated all trait implementations
  • Updated all decorator patterns
  • Updated all test cases
  • Updated FFI bindings
  • Verified code compiles with new trait structure

Fixes #5

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #5
@konard konard self-assigned this Sep 11, 2025
konard and others added 2 commits September 11, 2025 13:56
This commit implements the changes requested in issue #5 to use
associated types instead of generic parameters for the Doublets trait.

Changes made:
- Updated Links trait: `Links<T>` -> `Links` with `type Item: LinkType`
- Updated Doublets trait: `Doublets<T>` -> `Doublets` (inherits Item from Links)
- Updated DoubletsExt trait: `DoubletsExt<T>` -> `DoubletsExt`
- Updated all implementations of these traits in Store and Unit Store
- Updated decorator structs to use associated types
- Updated all usage sites across the codebase and tests
- Updated FFI bindings to use new syntax

This makes the API more idiomatic as suggested, allowing usage like:
- `struct Wrapper<D: Doublets>` instead of `struct Wrapper<T, D: Doublets<T>>`
- The type `T` is now accessible as `D::Item`

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] Use associated types in Doublets trait Use associated types in Doublets trait Sep 11, 2025
@konard konard marked this pull request as ready for review September 11, 2025 11:13
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.

Use associated types in Doublets trait

1 participant