mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
137543bb93
Move ShapePkg to types, and change types.NewNamed to automatically set IsShape/HasShape if a type is in the shapes pkg. This means that imported shape types will automatically have the correct IsShape/HasShape flags, even though we are not explicitly exporting/importing those flags. Updates #48337 Change-Id: I8b6131a663205f73f395943c9d0c8bdb2a213401 Reviewed-on: https://go-review.googlesource.com/c/go/+/349869 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
26 lines
508 B
Go
26 lines
508 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
|
|
|
|
type Container[T any] struct {
|
|
X T
|
|
}
|
|
|
|
func NewContainer[T any](x T) *Container[T] {
|
|
return &Container[T]{x}
|
|
}
|
|
|
|
type MetaContainer struct {
|
|
C *Container[Value]
|
|
}
|
|
|
|
type Value struct{}
|
|
|
|
func NewMetaContainer() *MetaContainer {
|
|
c := NewContainer(Value{})
|
|
// c := &Container[Value]{Value{}} // <-- this works
|
|
return &MetaContainer{c}
|
|
}
|