Updated manual
This commit is contained in:
parent
19076ee4a1
commit
398af0f467
|
@ -191,7 +191,10 @@ fn identity[T: int | int32](x: T): T {
|
|||
This code will, again, fail to compile: this is because as far as peon is concerned, `foo` is not
|
||||
defined for both `int` and `int32` _at the same time_. In order for that to work, `foo` would need
|
||||
to be rewritten with `T: int32 | int` as its generic argument type in order to avoid the ambiguity
|
||||
(or `identity` could be rewritten to use automatic types instead, both are viable options).
|
||||
(or `identity` could be rewritten to use automatic types instead, both are viable options). Obviously,
|
||||
the above snippet would fail to compile if `foo` were not defined for all the types specified in the
|
||||
type constraint for `identity` as well (this is because, counterintuitively, when matching generics
|
||||
`int32 | int` does _not_ mean "either of these types", but rather "_both_ of these types at once")
|
||||
|
||||
|
||||
#### More generics
|
||||
|
|
Loading…
Reference in New Issue