From 6e92d7d5de6ba6b346b0c8d27c1801b5a0c73580 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 26 Jul 2023 18:12:27 +0300 Subject: [PATCH] [#49] util/proto: Make `NestedStructure*` generic Signed-off-by: Evgenii Stratonikov --- util/proto/marshal.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/proto/marshal.go b/util/proto/marshal.go index 7bc8162..e345492 100644 --- a/util/proto/marshal.go +++ b/util/proto/marshal.go @@ -255,7 +255,7 @@ func NestedStructurePrefix(field int64) (prefix uint64, ln int) { return prefix, VarUIntSize(prefix) } -func NestedStructureMarshal(field int64, buf []byte, v stableMarshaller) int { +func NestedStructureMarshal[T stableMarshaller](field int64, buf []byte, v T) int { n := v.StableSize() if n == 0 { return 0 @@ -269,7 +269,7 @@ func NestedStructureMarshal(field int64, buf []byte, v stableMarshaller) int { return offset + n } -func NestedStructureSize(field int64, v stableMarshaller) (size int) { +func NestedStructureSize[T stableMarshaller](field int64, v T) (size int) { n := v.StableSize() if n == 0 { return 0