From 53bcbd923964d043932c119fc3e721242e126e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Mortensen?= Date: Fri, 3 Nov 2023 13:14:19 +0000 Subject: [PATCH] core: implement field::ValidLen for slices There used to be a length restriction on the arrays usable to construct `ValueSet`s, but this was due to Rust compiler limitations that no longer exist. After that restriction was removed, the `ValidLen` trait was kept around but implemented for statically-sized arrays of all lengths. While in theory this allows `ValueSet`s to be constructed from arrays of arbitrary length, the size of the arrays must still be known at compile time. Now that there is no longer a restriction on the length of arrays, slices could in theory be used as well (since they meet the supertrait requirement of `ValidLen`), but no implementation of the trait exists. Adding an implementation of `ValidLen` for slices is straightforward. Refs: #2508 --- tracing-core/src/field.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tracing-core/src/field.rs b/tracing-core/src/field.rs index 90c4eaa85d..5c9a2d12a0 100644 --- a/tracing-core/src/field.rs +++ b/tracing-core/src/field.rs @@ -1081,6 +1081,7 @@ mod private { pub trait ValidLen<'a>: Borrow<[(&'a Field, Option<&'a (dyn Value + 'a)>)]> {} impl<'a, const N: usize> ValidLen<'a> for [(&'a Field, Option<&'a (dyn Value + 'a)>); N] {} + impl<'a> ValidLen<'a> for &[(&'a Field, Option<&'a (dyn Value + 'a)>)] {} } #[cfg(test)]