From 69d1c8e948f8a3e69bdaeefa0e44c4a41e4abf86 Mon Sep 17 00:00:00 2001 From: 132ikl <132@ikl.sh> Date: Wed, 19 Mar 2025 22:59:06 -0400 Subject: [PATCH] Add compile-time assertion of `Value`'s size (#15362) # Description Adds an assertion of `Value`'s size, similar to `Instruction` and `Expr`. --- crates/nu-protocol/src/value/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index fb189daca85..428031c48f8 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -168,6 +168,11 @@ pub enum Value { }, } +// This is to document/enforce the size of `Value` in bytes. +// We should try to avoid increasing the size of `Value`, +// and PRs that do so will have to change the number below so that it's noted in review. +const _: () = assert!(std::mem::size_of::() <= 48); + impl Clone for Value { fn clone(&self) -> Self { match self {