Skip to content

Conversation

@kpreid
Copy link
Contributor

@kpreid kpreid commented Oct 15, 2024

Currently, rustdoc only displays repr(transparent) if the type’s fields are public, so there is no indication in the documentation that NotNan has repr(transparent). Even if it was visible, there is not currently a strong consensus that such a repr may be assumed to be a stable part of the public API.

Therefore, I propose to add paragraphs to NotNan and OrderedFloat’s documentation guaranteeing the repr. I also mentioned bytemuck so as to not be encouraging unsafe code, though the phrasing isn’t great.

I’ve also added impl bytemuck::TransparentWrapper for OrderedFloat, which simply gives another way for users to perform conversions, more strongly typed than bytemuck’s casts to/from bytes.

Currently, rustdoc only displays `repr(transparent)` if the type’s
fields are public, so there is no indication in the documentation that
`NotNan` has `repr(transparent)`. Even if it was visible, there is not
currently a strong consensus that such a repr may be assumed to be a
stable part of the public API.

Therefore, add paragraphs to `NotNan` and `OrderedFloat`’s documentation
guaranteeing the repr. I also mentioned `bytemuck` so as to not be
encouraging unsafe code, though the phrasing isn’t great.
This gives a more strongly-typed way for users to take advantage of
`OrderedFloat`’s representation.
Copy link
Collaborator

@mbrubeck mbrubeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mbrubeck mbrubeck merged commit e2c7a82 into reem:master Oct 15, 2024
2 checks passed
@kpreid kpreid deleted the transparent branch October 15, 2024 18:43
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