fix: Remove unnecessary double wrap/unwrap#37
Conversation
|
Hi, thank you for this PR! Going through the types has been on my to-do list for a while, but I've been putting it off, hoping that some of the proposals for Go's generics (which feel somewhat lacking) would eventually get merged. If that happened, I’d have to redesign most of the API anyway. Not being able to express type constraints (e.g., specifying that However, since you started looking into this now, I went ahead and cherry-picked this commit to #36 (since it touches the same functions and makes some of the code there redundant). I also simplified the batch functions in the same way and made the wrap function cleaner, as well as added a couple of tests. |
|
Nice, thanks! Sorry if I'm picking at details too much, mostly trying to get familiar with the code at the moment :) |
Hi again! I wonder if I got this right, something which confused me while reviewing #36 .
For the generic functions, T is the type stored in the cache and V is the type that is returned from
fetchFnandGetOrFetch. Since we wrap thefetchFnalready ingetFetchhere to return T:Doesn't it already have the correct type for storage in the cache? And the result is later unwrapped to V again here in
GetOrFetch.So we shouldn't need to do the same wrap/unwrap process in
makeCallandcallAndCache?