mirror of
https://github.com/golang/go
synced 2024-11-24 07:50:13 -07:00
79ff663754
Now that we permit arbitrary types as constraints, we no longer need them. For #48424 Change-Id: I15fef26a563988074650cb0801895b002c44148a Reviewed-on: https://go-review.googlesource.com/c/go/+/359258 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
17 lines
296 B
Go
17 lines
296 B
Go
// compile -G=3
|
|
|
|
// 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 p
|
|
|
|
func f[T ~chan E, E any](e E) T {
|
|
ch := make(T)
|
|
go func() {
|
|
defer close(ch)
|
|
ch <- e
|
|
}()
|
|
return ch
|
|
}
|