Add `CollectRowsInto` to allow custom slice types
This PR adds a new method CollectRowsInto to allow overriding the slice type returned
by CollectRows. This change is backwards compatible.
type User struct{}
type Users []User
// ...
CollectRows[User] // -> []User (can't override)
CollectRowsInto[Users] // -> Users (implicit)
CollectRowsInto[Users, User] // -> Users (explicit)
Do I understand correctly that this is to save a type cast or is it doing more? Without tests its a bit hard to follow the intent.
Oh yes, it's pure type gimmicks, there's no new logic involved.
As far as I can tell you can do the same by assigning the result of CollectRows with = to a variable of your desired type rather than using := to create it. It saves one line of code (or two if err needs to be declared).
I'm somewhat inclined against adding a public function to save a line of code on the basis of avoiding the increase in API surface unless it was going to be very frequently used. And anyone that is doing that type operation frequently can add this helper function to their project.