Skip to content

Commit

Permalink
Clarify comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gio256 committed Jun 29, 2024
1 parent b3c0169 commit 0a295d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 1 addition & 3 deletions proc_macro/src/impls/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ pub(crate) fn try_derive(ast: DeriveInput) -> Result<proc_macro2::TokenStream> {

// SAFETY: A struct generic over T has the same layout as an array [T; N] if:
// - The struct is `#[repr(C)]`.
// - Every field of the struct is either T or a type with the same alignment as
// T and a size of `size_of::<T>() * M` where M <= N. i.e. every field is one
// of T, [T; M], or a type with the same layout as [T; M].
// - Every field is one of T, [T; M], or a type with the same layout as [T; M],
// - The total number of elements of type T is N.
// https://doc.rust-lang.org/reference/type-layout.html#reprc-structs
// https://doc.rust-lang.org/reference/type-layout.html#array-layout
Expand Down
4 changes: 1 addition & 3 deletions proc_macro/src/impls/deref_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ pub(crate) fn try_derive(ast: DeriveInput) -> Result<proc_macro2::TokenStream> {

// SAFETY: A struct generic over T has the same layout as an array [T; N] if:
// - The struct is `#[repr(C)]`.
// - Every field of the struct is either T or a type with the same alignment as
// T and a size of `size_of::<T>() * M` where M <= N. i.e. every field is one
// of T, [T; M], or a type with the same layout as [T; M].
// - Every field is one of T, [T; M], or a type with the same layout as [T; M],
// - The total number of elements of type T is N.
// https://doc.rust-lang.org/reference/type-layout.html#reprc-structs
// https://doc.rust-lang.org/reference/type-layout.html#array-layout
Expand Down
12 changes: 6 additions & 6 deletions proc_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
//! and [`DerefMut`] with target `[T; N]` where `N` is the number of fields in
//! the struct.
//!
//! These implementations employ unsafe code and as such place a burden on the
//! user to ensure their safe usage. Please see the respective macro
//! implementations to understand the conditions that should be upheld by any
//! struct deriving [`Columns`] or [`DerefColumns`]. In short, the struct must
//! be `#[repr(C)]` and all fields must be one of `T`, `[T; M]`, or a type with
//! the same layout as `[T; M]`.
//! These implementations employ unsafe code and place a burden on the user to
//! ensure their safe usage. Please see the respective macro implementations to
//! understand the conditions that should be upheld by any struct deriving
//! [`Columns`] or [`DerefColumns`]. In short, the struct must be `#[repr(C)]`
//! and all fields must be one of `T`, `[T; M]`, or a type with the same layout
//! as `[T; M]`.
//!
//! [`Borrow`]: ::core::borrow::Borrow
//! [`BorrowMut`]: ::core::borrow::BorrowMut
Expand Down

0 comments on commit 0a295d7

Please sign in to comment.