go/test/typeparam/issue50121.dir/a.go
Ian Lance Taylor 070951c5dc constraints: remove package
It has moved to golang.org/x/exp/constraints. Perhaps it will move
back to the standard library in a future release.

For golang/go#45458
Fixes golang/go#50792

Change-Id: I93aa251a7afe7b329a3d3faadc0c5d6388b1f0e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/382460
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-03 03:13:33 +00:00

27 lines
495 B
Go

// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package a
import (
"math/rand"
)
type Integer interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
type Builder[T Integer] struct{}
func (r Builder[T]) New() T {
return T(rand.Int())
}
var IntBuilder = Builder[int]{}
func BuildInt() int {
return IntBuilder.New()
}