Skip to content

Conversation

@sffc
Copy link
Member

@sffc sffc commented Feb 7, 2026

Fixes #7607
Replaces #5101
See #6915

I was trying to use ref_cast, but found that it had multiple deficiencies:

  1. Doesn't support standard pointer wrappers like Box
  2. Implements a trait by default, which can violate field invariants
    • Note: it supports a private conversion function via RefCastCustom
  3. Not highly suited for use as a dev-dependency only

So, I made my own proc macro, TransparentCast.

The use cases are the same as RefCast, as listed in #7607, but it resolves the deficiencies listed above.

I am as sensitive to dependency bloat as everyone else, so I specifically designed this derive to be usable as a dev-dependency. See the example. However, this PR is not intended to be the place to debate whether we decide to use that strategy in icu4x.

@sffc sffc marked this pull request as ready for review February 7, 2026 19:52
@sffc sffc requested a review from a team as a code owner February 7, 2026 19:52
@sffc sffc requested a review from Manishearth February 7, 2026 19:52
@sffc sffc mentioned this pull request Feb 7, 2026
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.

Low-dependency ref-cast

1 participant