diamondburned commented on issue #21929: URL: https://github.com/apache/beam/issues/21929#issuecomment-1639070206
To slightly contribute to the wrapper library, this function adds a bit more runtime type safety for converting `beam.PCollection`s: ```go // CollectionOf returns a typed PCollection converted from the given // beam.PCollection. It exists for documenting purposes. If T doesn't match // with what is actually in pc, the function panics. func CollectionOf[T any](pc beam.PCollection) PCollection[T] { var z T if reflect.TypeOf(z) != pc.Type().Type() { panic(fmt.Sprintf( "CollectionOf given unexpected PCollection type: expected %v, got %v", reflect.TypeOf(z), pc.Type().Type())) } return PCollection[T](pc) } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org