Skip to content

Commit a056801

Browse files
committed
feat: put len before xs
1 parent 2c92a59 commit a056801

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/array_string.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ use serde::{Serialize, Deserialize, Serializer, Deserializer};
3131
/// The string is a contiguous value that you can store directly on the stack
3232
/// if needed.
3333
#[derive(Copy)]
34+
#[repr(C)]
3435
pub struct ArrayString<const CAP: usize> {
3536
// the `len` first elements of the array are initialized
36-
xs: [MaybeUninit<u8>; CAP],
3737
len: LenUint,
38+
xs: [MaybeUninit<u8>; CAP],
3839
}
3940

4041
impl<const CAP: usize> Default for ArrayString<CAP>

src/arrayvec.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ use crate::utils::MakeMaybeUninit;
3939
///
4040
/// It offers a simple API but also dereferences to a slice, so that the full slice API is
4141
/// available. The ArrayVec can be converted into a by value iterator.
42+
#[repr(C)]
4243
pub struct ArrayVec<T, const CAP: usize> {
44+
len: LenUint,
4345
// the `len` first elements of the array are initialized
4446
xs: [MaybeUninit<T>; CAP],
45-
len: LenUint,
4647
}
4748

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

0 commit comments

Comments
 (0)