Skip to content

Commit

Permalink
repr(transparent) for option and array
Browse files Browse the repository at this point in the history
* enables/eases repr()-setting of containing structs
* enforces same layout as inner
* not breaking
  • Loading branch information
jordens committed Nov 14, 2022
1 parent 7f1a7ae commit 126be37
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use core::ops::{Deref, DerefMut};
/// An `Array` can be constructed using [`From<[T; N]>`](From)/[`Into<miniconf::Array>`]
/// and the contained value can be accessed through [`Deref`]/[`DerefMut`].
#[derive(Clone, Copy, PartialEq, Eq, Debug, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct Array<T, const N: usize>([T; N]);

impl<T, const N: usize> Deref for Array<T, N> {
Expand Down
1 change: 1 addition & 0 deletions src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use core::ops::{Deref, DerefMut};
serde::Serialize,
serde::Deserialize,
)]
#[repr(transparent)]
pub struct Option<T>(core::option::Option<T>);

impl<T> Deref for Option<T> {
Expand Down

0 comments on commit 126be37

Please sign in to comment.