so am I right in thinking that every rust function with a generic return, e.g. collect(), sum(), into(), is implemented by constraining the return to implement some trait and then just calling that trait?
What's happening here is that SQLite needs a C function pointer for "body of this custom SQL function" (which takes a `void *` of whatever "context" you want), and then another function pointer to drop that context. 1/
-
-
We wanted an API where you just give us a closure with the function body, so our context is just a boxed trait object for that (wrapped in our own closure to handle deserialization of arguments and serialization of return value) 2/
-
Actually it's not even a trait object. It's just a generic `Box<T>` -- anyway I found it super neat that you can do this even with `extern "C" fn`s. Just give it the generic type for the actual closure you passed it and you'll get what you need for C interop
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.