From c1cc1c82cc72112d83f45fd47aa92cde04820942 Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Sun, 24 Dec 2023 13:12:16 +0100 Subject: [PATCH] Lock out new direct construction of `Record` (#11414) # Description With #11386 we don't have any nushell-internal code directly accessing the `vals` field of `Record`, so let's make it private so everyone in the future uses the checked ways guaranteeing matching cols/vals. The `cols` feel has to remain pub for now as `rename` still directly mutates this field. See #11020 for challenges for this refactor. # Plugin-Author-Facing Changes This is a breaking change for outside plugins that relied on the `pub` fields. --- crates/nu-protocol/src/value/record.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/nu-protocol/src/value/record.rs b/crates/nu-protocol/src/value/record.rs index c3f4590b04..6e5ee2d3a7 100644 --- a/crates/nu-protocol/src/value/record.rs +++ b/crates/nu-protocol/src/value/record.rs @@ -6,8 +6,12 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct Record { + /// Don't use this field publicly! + /// + /// Only public as command `rename` is not reimplemented in a sane way yet + /// Using it or making `vals` public will draw shaming by @sholderbach pub cols: Vec, - pub vals: Vec, + vals: Vec, } impl Record {