@@ -18,6 +18,7 @@ package reflect
1818import  (
1919	"internal/abi" 
2020	"internal/goarch" 
21+ 	"iter" 
2122	"runtime" 
2223	"strconv" 
2324	"sync" 
@@ -255,6 +256,22 @@ type Type interface {
255256	// CanSeq2 reports whether a [Value] with this type can be iterated over using [Value.Seq2]. 
256257	CanSeq2 () bool 
257258
259+ 	// Fields yields each field of a struct type. 
260+ 	// It panics if the type's Kind is not Struct. 
261+ 	Fields () iter.Seq [StructField ]
262+ 
263+ 	// Methods yields each method in the type's method set. 
264+ 	// See [Type.Method] for information on the yielded methods. 
265+ 	Methods () iter.Seq [Method ]
266+ 
267+ 	// Ins yields each input parameter of a function type, in order. 
268+ 	// It panics if the type's Kind is not Func. 
269+ 	Ins () iter.Seq [Type ]
270+ 
271+ 	// Outs yields each output parameter of a function type, in order. 
272+ 	// It panics if the type's Kind is not Func. 
273+ 	Outs () iter.Seq [Type ]
274+ 
258275	common () * abi.Type 
259276	uncommon () * uncommonType 
260277}
@@ -934,6 +951,46 @@ func canRangeFunc2(t *abi.Type) bool {
934951	return  yield .InCount  ==  2  &&  yield .OutCount  ==  1  &&  yield .Out (0 ).Kind () ==  abi .Bool 
935952}
936953
954+ func  (t  * rtype ) Fields () iter.Seq [StructField ] {
955+ 	return  func (yield  func (StructField ) bool ) {
956+ 		for  i  :=  range  t .NumField () {
957+ 			if  ! yield (t .Field (i )) {
958+ 				return 
959+ 			}
960+ 		}
961+ 	}
962+ }
963+ 
964+ func  (t  * rtype ) Methods () iter.Seq [Method ] {
965+ 	return  func (yield  func (Method ) bool ) {
966+ 		for  i  :=  range  t .NumMethod () {
967+ 			if  ! yield (t .Method (i )) {
968+ 				return 
969+ 			}
970+ 		}
971+ 	}
972+ }
973+ 
974+ func  (t  * rtype ) Ins () iter.Seq [Type ] {
975+ 	return  func (yield  func (Type ) bool ) {
976+ 		for  i  :=  range  t .NumIn () {
977+ 			if  ! yield (t .In (i )) {
978+ 				return 
979+ 			}
980+ 		}
981+ 	}
982+ }
983+ 
984+ func  (t  * rtype ) Outs () iter.Seq [Type ] {
985+ 	return  func (yield  func (Type ) bool ) {
986+ 		for  i  :=  range  t .NumOut () {
987+ 			if  ! yield (t .Out (i )) {
988+ 				return 
989+ 			}
990+ 		}
991+ 	}
992+ }
993+ 
937994// add returns p+x. 
938995// 
939996// The whySafe string is ignored, so that the function still inlines 
0 commit comments