Skip to content

Commit

Permalink
Rollup merge of rust-lang#81879 - imbrem:make-reverse-repr-transparen…
Browse files Browse the repository at this point in the history
…t, r=m-ou-se

Added #[repr(transparent)] to core::cmp::Reverse

I found casting from an `&T` to an `&Reverse<T>` potentially useful, but found that `Reverse` was not `#[repr(transparent)]`, so after asking about it [on Reddit](https://www.reddit.com/r/rust/comments/le60uv/make_stdcmpreverse_reprtransparent_and_add_a/), I decided to go ahead and make a pull request which simply adds the attribute to the struct.
  • Loading branch information
m-ou-se committed Mar 9, 2021
2 parents ad89b9e f847ff1 commit d3f7b9a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 579,7 @@ impl Ordering {
/// ```
#[derive(PartialEq, Eq, Debug, Copy, Clone, Default, Hash)]
#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
#[repr(transparent)]
pub struct Reverse<T>(#[stable(feature = "reverse_cmp_key", since = "1.19.0")] pub T);

#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
Expand Down

0 comments on commit d3f7b9a

Please sign in to comment.