8 ms·
Sometimes you need to instantiate a struct, usually in a test, that contains a bunch of pointers to built in types. Say a struct representing a json request bod
by 0x6877 4y ago
Sometimes you need to instantiate a struct, usually in a test, that contains a bunch of pointers to built in types. Say a struct representing a json request body with optional fields. You can’t just take a pointer to a string literal `&”foo”` and making a variable for everyone of these fields is cumbersome so you have a function that returns a pointer to the value it’s given.
I’ve personally never needed it outside of tests.