Skip to content

Commit

Permalink
feat: put len before xs
Browse files Browse the repository at this point in the history
  • Loading branch information
JakkuSakura authored and bluss committed Mar 7, 2024
1 parent 27401fb commit 1cd7b9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/array_string.rs
Expand Up @@ -31,10 +31,11 @@ use serde::{Serialize, Deserialize, Serializer, Deserializer};
/// The string is a contiguous value that you can store directly on the stack
/// if needed.
#[derive(Copy)]
#[repr(C)]
pub struct ArrayString<const CAP: usize> {
// the `len` first elements of the array are initialized
xs: [MaybeUninit<u8>; CAP],
len: LenUint,
xs: [MaybeUninit<u8>; CAP],
}

impl<const CAP: usize> Default for ArrayString<CAP>
Expand Down
3 changes: 2 additions & 1 deletion src/arrayvec.rs
Expand Up @@ -39,10 +39,11 @@ use crate::utils::MakeMaybeUninit;
///
/// It offers a simple API but also dereferences to a slice, so that the full slice API is
/// available. The ArrayVec can be converted into a by value iterator.
#[repr(C)]
pub struct ArrayVec<T, const CAP: usize> {
len: LenUint,
// the `len` first elements of the array are initialized
xs: [MaybeUninit<T>; CAP],
len: LenUint,
}

impl<T, const CAP: usize> Drop for ArrayVec<T, CAP> {
Expand Down

0 comments on commit 1cd7b9d

Please sign in to comment.