Add expand() to read tagged-pointer size types back as enums - #1129
Merged
nicoburns merged 1 commit intoAug 21, 2026
Conversation
Since the size style types became tagged pointers rather than enums it is awkward to recover the original value of a property, which integrations such as egui_taffy need in order to inspect a style. Give LengthPercentage, LengthPercentageAuto, Dimension, MinTrackSizingFunction and MaxTrackSizingFunction an expand() method returning a matching Expanded* enum, with From conversions in both directions so the value round-trips.
nicoburns
force-pushed
the
expand-tagged-pointer-sizes
branch
from
August 21, 2026 15:02
30c126d to
e5e96dc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #824.
The size style types (
LengthPercentage,Dimension, and the grid track sizing functions) became tagged pointers overCompactLengtha while back, which is great for size but means there's no longer an easy way to read the original value back out. As the issue points out, integrations likeegui_taffyneed to inspect aStyleand branch on what each property actually is, and today the only way to do that is to go throughinto_raw()and match on the raw tag yourself.This adds an
expand()method to each ofLengthPercentage,LengthPercentageAuto,Dimension,MinTrackSizingFunctionandMaxTrackSizingFunctionthat returns a matchingExpanded*enum (ExpandedLengthPercentage,ExpandedDimension, and so on). The variants line up one-to-one with each type's public constructors, and there areFromimpls in both directions so a value round-trips, e.g.Dimension::from(dim.expand()) == dim.calc()is represented as an opaque*const ()variant behind thecalcfeature, matching the existingcalc/into_rawsurface, so nothing extra is exposed when that feature is off.I went with the
ExpandedLengthPercentageshape you sketched in the issue. I held off on the separate lightweightLengthPercentageTagdiscriminant enums for now, mainly because a naturaltag()accessor would collide with the existingDimension::tag() -> usizeand I wasn't sure what you'd want to call it. Happy to add those in this PR if you'd like them, just let me know the naming you'd prefer.Round-trip tests for every variant (including
calc) live next to each type, and there's a CHANGELOG entry under Added.cargo fmt,cargo clippy --all-targetsand the lib tests are all clean.