From 1cd7b9d85909b79eeaa90f122ca46e5c20ba9d00 Mon Sep 17 00:00:00 2001 From: JakkuSakura Date: Tue, 19 Dec 2023 10:48:49 +0900 Subject: [PATCH] feat: put len before xs --- src/array_string.rs | 3 ++- src/arrayvec.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/array_string.rs b/src/array_string.rs index 90cfc09..7f6e299 100644 --- a/src/array_string.rs +++ b/src/array_string.rs @@ -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 { // the `len` first elements of the array are initialized - xs: [MaybeUninit; CAP], len: LenUint, + xs: [MaybeUninit; CAP], } impl Default for ArrayString diff --git a/src/arrayvec.rs b/src/arrayvec.rs index d51fbf7..6f64ba5 100644 --- a/src/arrayvec.rs +++ b/src/arrayvec.rs @@ -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 { + len: LenUint, // the `len` first elements of the array are initialized xs: [MaybeUninit; CAP], - len: LenUint, } impl Drop for ArrayVec {