123456789101112131415161718192021 |
-
- # More on type sets
- Qinghe
- 21 Jan 2022
-
-
- ## Both elements and methods in constraints
- 约束中可以同时约束元素(具体类型、近似类型、联合类型)和方法。
-
- .code codes/type_sets.go /StringableSignedInteger OMIT/,/StringableSignedInteger OMIT/
-
- 满足这个约束的类型必须满足两个条件:
- 1. 底层类型是int/int8/int16/int32/int64类型其中之一
- 2. 这个类型必须有`String() string`方法
-
- 要注意:
-
- `'~'`符号是必要的,因为int类型本身没有实现`String() string`方法
-
- ## Composite types in constraints
|