Skip to content

Conversation

@RottenRat
Copy link
Contributor

Overview

This refactors (*Wrapped).UnmarshalTo to relax the type-matching rule and fix panic cases:

  • Replaces the strict rw.Type() == rv.Type() comparison with rw.Type().AssignableTo(rv.Elem().Type()).
  • Adds defensive handling of *T(nil) → value T (writes zero-value instead of propagating nil).
  • Supports one-level pointer unwrapping when Wrapped is a **T and the target is *T.
  • Extends the test-suite with new cases

Overall, the helper becomes a more intuitive drop-in for typical hook scenarios (templating, caching, deserialising to interfaces).

What this PR does / why we need it

We need to cover stable code with no panic

Special notes for your reviewer

The key design question: Do we want the relaxed AssignableTo contract, or should we keep the old, stricter equality check?

Sinelnikov Michail added 3 commits July 16, 2025 17:51
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
@RottenRat RottenRat self-assigned this Jul 17, 2025
Sinelnikov Michail added 3 commits August 21, 2025 15:53
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
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.

2 participants