It would be nice if the compiler could figure this out (both for *new(T)
and zeroT).
When 61372 is implemented it will certainly be easier to just detect the
zero builtin. Perhaps we should just wait for that.
On Monday, August 14, 2023 at 5:31:16 PM UTC-7 Diego Augusto Molina wrote:
> Thank yo
Thank you very much, that's actually what I was looking for.
On Monday, 14 August 2023 at 13:57:35 UTC-3 Axel Wagner wrote:
> You might be interested in https://github.com/golang/go/issues/61372
>
> On Mon, Aug 14, 2023 at 3:52 PM Diego Augusto Molina <
> diegoaugu...@gmail.com> wrote:
>
>> Hi, t
You might be interested in https://github.com/golang/go/issues/61372
On Mon, Aug 14, 2023 at 3:52 PM Diego Augusto Molina <
diegoaugustomol...@gmail.com> wrote:
> Hi, thank you for reading. Whenever I need to use a zero value for a
> generic type in a func I do something like the following:
>
>
Hi, thank you for reading. Whenever I need to use a zero value for a
generic type in a func I do something like the following:
func SetZero[T any](pt *T) T {
var zeroT T
*pt = zeroT
}
That's all good, but I wonder how, if possible, it could be proved to the
compiler that zeroT is the