tlv: add Zero() method for OptionalRecordT
Most of the time with wire messages, we'll have the wrapped record, so this is useful when decoding into a blank instance of the record's value.
This commit is contained in:
1 file changed
+5
@@ -140,6 +140,11 @@ func (o *OptionalRecordT[T, V]) UnwrapOrErrV(err error) (V, error) {
|
|||||||
return inner.Val, nil
|
return inner.Val, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Zero returns a zero value of the record type.
|
||||||
|
func (t *OptionalRecordT[T, V]) Zero() RecordT[T, V] {
|
||||||
|
return ZeroRecordT[T, V]()
|
||||||
|
}
|
||||||
|
|
||||||
// SomeRecordT creates a new OptionalRecordT type from a given RecordT type.
|
// SomeRecordT creates a new OptionalRecordT type from a given RecordT type.
|
||||||
func SomeRecordT[T TlvType, V any](record RecordT[T, V]) OptionalRecordT[T, V] {
|
func SomeRecordT[T TlvType, V any](record RecordT[T, V]) OptionalRecordT[T, V] {
|
||||||
return OptionalRecordT[T, V]{
|
return OptionalRecordT[T, V]{
|
||||||
|
|||||||
Reference in new issue
Block a user