News for hackers. Stuff that matters.
Re:Golang generics proposal has been accepted by pjungwir on Wednesday February 10, 2021 @03:52PM (#26094612)
I've been experimenting with Rust's Rocket webapp framework, and as much as I like it, I agree it's very annoying how a struct can't permit nulls in one context but not another. I wish there were an easy solution that didn't require near-identical struct definitions and excess copying memory from one place to another.
Re:Golang generics proposal has been accepted by sdfsfsf3kjdf on Wednesday February 10, 2021 @04:18PM (#26094949)
In Rust you can solve this via derive or a macro. Typescript's conditional types and the associated utility types are a nice solution to this problem as well. You can do a ton with Partial, Required, Pick, Omit, Exclude etc.
Re:Golang generics proposal has been accepted by pjungwir on Thursday February 11, 2021 @12:42PM (#26104655)
Thank you both for these tips. I'll see what I can figure out! :-)
Re:Golang generics proposal has been accepted by wtetzner on Wednesday February 10, 2021 @04:11PM (#26094863)
Seems like a good opportunity for a custom derive.