github.com/protolambda/zssz@v0.1.5/types/limit.go (about) 1 package types 2 3 import ( 4 "fmt" 5 "github.com/protolambda/zssz/lists" 6 "reflect" 7 ) 8 9 var listType = reflect.TypeOf((*lists.List)(nil)).Elem() 10 11 func ReadListLimit(typ reflect.Type) (uint64, error) { 12 ptrTyp := reflect.PtrTo(typ) 13 if !ptrTyp.Implements(listType) { 14 return 0, fmt.Errorf("*typ (pointer type) is not a ssz list") 15 } 16 typedNil := reflect.New(ptrTyp).Elem().Interface().(lists.List) 17 return typedNil.Limit(), nil 18 }