Skip to content

Conversation

@juntyr
Copy link
Owner

@juntyr juntyr commented Nov 13, 2024

The original implementation, which used a Discriminant enum with per-discriminant-type variants, relied on knowing the exact type that the discriminant resolves to. Extracting this type required the use of perma-unstable features and specialisation (or at least type name based runtime specialisation).

Since we have moved away from these unstable features and now no longer extract the discriminant type but leave it as opaque, it is also no longer possible to know what type an enum discriminant should use.

Since the enum discriminant type is already encoded in the enum #[repr] attribute, what we really only care about is the numerical value of the discriminant. We now store this numerical value in negabinary representation, which has unique representations for signed and unsigned values and is independent of the numerical type size.

  • documentation
  • tests
  • review

@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 89.53488% with 9 lines in your changes missing coverage. Please review.

Project coverage is 21.38%. Comparing base (73bbc87) to head (fce7a27).

Files with missing lines Patch % Lines
src/ser.rs 0.00% 8 Missing ⚠️
src/discriminant.rs 98.71% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##            main      #16       +/-   ##
==========================================
+ Coverage   0.00%   21.38%   +21.38%     
==========================================
  Files          2        3        +1     
  Lines        337      360       +23     
==========================================
+ Hits           0       77       +77     
+ Misses       337      283       -54     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@juntyr juntyr marked this pull request as ready for review November 14, 2024 09:20
@juntyr juntyr mentioned this pull request Nov 14, 2024
14 tasks
@juntyr juntyr merged commit 49bf2c0 into main Nov 14, 2024
7 checks passed
@juntyr juntyr deleted the discriminant-value branch November 14, 2024 13:56
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