summaryrefslogtreecommitdiff
path: root/serde_v8/magic/bytestring.rs
diff options
context:
space:
mode:
Diffstat (limited to 'serde_v8/magic/bytestring.rs')
-rw-r--r--serde_v8/magic/bytestring.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/serde_v8/magic/bytestring.rs b/serde_v8/magic/bytestring.rs
index c7c1b9de8..5580fdced 100644
--- a/serde_v8/magic/bytestring.rs
+++ b/serde_v8/magic/bytestring.rs
@@ -5,6 +5,8 @@ use crate::Error;
use smallvec::SmallVec;
use std::mem::size_of;
+const USIZE2X: usize = size_of::<usize>() * 2;
+
#[derive(
PartialEq,
Eq,
@@ -18,14 +20,15 @@ use std::mem::size_of;
)]
#[as_mut(forward)]
#[as_ref(forward)]
-pub struct ByteString(SmallVec<[u8; 16]>);
+pub struct ByteString(SmallVec<[u8; USIZE2X]>);
impl_magic!(ByteString);
-// const-assert that Vec<u8> and SmallVec<[u8; 16]> have a same size.
+// const-assert that Vec<u8> and SmallVec<[u8; size_of::<usize>() * 2]> have a same size.
// Note from https://docs.rs/smallvec/latest/smallvec/#union -
// smallvec can still be larger than Vec if the inline buffer is
// larger than two machine words.
-const _: () = assert!(size_of::<Vec<u8>>() == size_of::<SmallVec<[u8; 16]>>());
+const _: () =
+ assert!(size_of::<Vec<u8>>() == size_of::<SmallVec<[u8; USIZE2X]>>());
impl ToV8 for ByteString {
fn to_v8<'a>(