feat: put len before xs

This commit is contained in:
JakkuSakura
2023-12-19 10:48:49 +09:00
committed by bluss
parent 27401fbc22
commit 1cd7b9d859
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -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>
+2 -1
View File
@@ -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> {