1// run 2 3// Copyright 2022 The Go Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file. 6 7package main 8 9func main() { 10 One[TextValue]() 11} 12 13func One[V Value]() { Two[Node[V]]() } 14 15func Two[V interface{ contentLen() int }]() { 16 var v V 17 v.contentLen() 18} 19 20type Value interface { 21 Len() int 22} 23 24type Node[V Value] struct{} 25 26func (Node[V]) contentLen() int { 27 var value V 28 return value.Len() 29} 30 31type TextValue struct{} 32 33func (TextValue) Len() int { return 0 } 34