From 7d5dca7ba38be487d04b6ba78e1d70530f635fee Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 31 Aug 2022 04:27:09 +0300 Subject: [PATCH] chore(tvix/eval): provide 'static references to "name"/"value" These static strings show up a bunch when dealing with the internals of attribute sets, and having them available as static references is required. Due to the way const expressions are evaluated, taking a reference to the existing NixString::NAME / NixString::VALUE items does not work and the references themselves need to be const-evaluated. Change-Id: If6e75847af978118a3b266fe6a3242321722434d Reviewed-on: https://cl.tvl.fyi/c/depot/+/6366 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/value/string.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tvix/eval/src/value/string.rs b/tvix/eval/src/value/string.rs index 65022b6cc..095f87645 100644 --- a/tvix/eval/src/value/string.rs +++ b/tvix/eval/src/value/string.rs @@ -60,7 +60,10 @@ impl Hash for NixString { impl NixString { pub const NAME: Self = NixString(StringRepr::Smol(SmolStr::new_inline("name"))); + pub const NAME_REF: &'static Self = &Self::NAME; + pub const VALUE: Self = NixString(StringRepr::Smol(SmolStr::new_inline("value"))); + pub const VALUE_REF: &'static Self = &Self::VALUE; pub fn as_str(&self) -> &str { match &self.0 {