packagebigintimport"math/big"var(Zero=big.NewInt(0)One=big.NewInt(1))// Clamp returns a new big.Int for `end` to which `end - start` <= size.// @note (start, end) is an inclusive rangefuncClamp(start,end*big.Int,sizeuint64)*big.Int{temp:=new(big.Int)count:=temp.Sub(end,start).Uint64()+1ifcount<=size{returnend}// we re-use the allocated temp as the new endtemp.Add(start,big.NewInt(int64(size-1)))returntemp}// Matcher returns an inner comparison function result for a big.IntfuncMatcher(numint64)func(*big.Int)bool{returnfunc(bi*big.Int)bool{returnbi.Int64()==num}}