Skip to content

Commit

Permalink
Implement TransparentWrapper for [T; 1], (T,), and (T, ())
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAdk committed Aug 18, 2024
1 parent 3c42ba7 commit 76791a7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ use super::*;
/// For a given `Wrapper` which implements `TransparentWrapper<Inner>`:
///
/// 1. `Wrapper` must be a wrapper around `Inner` with an identical data
/// representations. This either means that it must be a
/// `#[repr(transparent)]` struct which contains a either a field of type
/// `Inner` (or a field of some other transparent wrapper for `Inner`) as
/// the only non-ZST field.
/// representations. This either means that it must be a
/// `#[repr(transparent)]` struct which contains a either a field of type
/// `Inner` or a field of some other transparent wrapper for `Inner` as the
/// only non-ZST field.
///
/// 2. Any fields *other* than the `Inner` field must be trivially constructable
/// ZSTs, for example `PhantomData`, `PhantomPinned`, etc. (When deriving
Expand Down Expand Up @@ -303,3 +303,4 @@ pub unsafe trait TransparentWrapper<Inner: ?Sized> {
}

unsafe impl<T> TransparentWrapper<T> for core::num::Wrapping<T> {}
unsafe impl<T> TransparentWrapper<T> for [T; 1] {}

0 comments on commit 76791a7

Please sign in to comment.