From f5f905cd70d8b1a8b11da3b42f8ed43adbb27631 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 5 May 2025 04:19:23 -0400 Subject: [PATCH] cl-ast: more generic impls for weight_of TODO: get rid of weight_of --- compiler/cl-ast/src/ast_impl/weight_of.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/cl-ast/src/ast_impl/weight_of.rs b/compiler/cl-ast/src/ast_impl/weight_of.rs index 1ebc1dd..63b02c4 100644 --- a/compiler/cl-ast/src/ast_impl/weight_of.rs +++ b/compiler/cl-ast/src/ast_impl/weight_of.rs @@ -567,13 +567,19 @@ impl WeightOf for Option { impl WeightOf for [T] { fn weight_of(&self) -> usize { - self.iter().map(|t| t.weight_of()).sum() + self.iter().map(WeightOf::weight_of).sum() + } +} + +impl WeightOf for Vec { + fn weight_of(&self) -> usize { + size_of::() + self.iter().map(WeightOf::weight_of).sum::() } } impl WeightOf for Box { fn weight_of(&self) -> usize { - (**self).weight_of() + (**self).weight_of() + size_of::() } }