-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For golang/go#48264 Change-Id: I94b1bae5b2a59753492148edf2e1f2931235802f Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/382976 Trust: Jonathan Amsterdam <[email protected]> Run-TryBot: Jonathan Amsterdam <[email protected]> Reviewed-by: Jamal Carvalho <[email protected]> TryBot-Result: kokoro <[email protected]>
- Loading branch information
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
A module that uses generics. | ||
|
||
-- go.mod -- | ||
module example.com/generics | ||
|
||
go 1.18 | ||
|
||
-- LICENSE -- | ||
$MITLicense | ||
|
||
-- file.go -- | ||
|
||
// Package generics uses generics. | ||
package generics | ||
|
||
import "constraints" | ||
|
||
func Min[T constraints.Ordered](a, b T) T { | ||
if a < b { | ||
return a | ||
} | ||
return b | ||
} | ||
|
||
type List[T any] struct { | ||
Val T | ||
Next *List[T] | ||
} | ||
|