2022-12-19 07:00:20 -09:00
|
|
|
package number
|
2022-12-18 20:47:42 -09:00
|
|
|
|
2023-01-13 17:40:24 -09:00
|
|
|
import (
|
2024-05-01 09:57:11 -08:00
|
|
|
"strconv"
|
2023-01-13 17:40:24 -09:00
|
|
|
)
|
2022-12-18 20:47:42 -09:00
|
|
|
|
2025-12-31 13:02:52 -09:00
|
|
|
// Integer is a constraint that permits any integer type.
|
|
|
|
|
type Integer interface {
|
|
|
|
|
~int | ~int8 | ~int16 | ~int32 | ~int64 |
|
|
|
|
|
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ParseInt[T Integer](s string) T {
|
2024-05-01 09:57:11 -08:00
|
|
|
r, _ := strconv.ParseInt(s, 10, 64)
|
|
|
|
|
return T(r)
|
|
|
|
|
}
|