Question: Is there no way to put statically defined named functions with all of them having the same signature in a collection type without using &dyn Fn or Box<dyn Fn>? My guess is no just want to make sure
-
-
-
Replying to @sgrif
Huh TIL you can use fn as a type. Thanks! :D It worked now I won't have a vtable lookup :D
3 replies 0 retweets 4 likes -
Replying to @mgattozzi @sgrif
The difference is that you cannot put closures in a fn type, since a fn type is a single pointer to the code.
1 reply 0 retweets 1 like -
Replying to @noop_noob @mgattozzi
Yup. To elaborate, fn types in Rust are the same concept as a C function pointer (Option<extern "C" fn()> is what you'd use for ffi if the pointer could be null).
1 reply 0 retweets 1 like -
If the c API takes a void* for user data you can use rust closures with it easily though. https://github.com/diesel-rs/diesel/blob/d3b1ce1db3bc4c419b661a3ad1f4ca5e3b85e20d/diesel/src/sqlite/connection/raw.rs#L143 …
1 reply 0 retweets 1 like
Also leads to the only place ever that a generic is used in argument position and you can't use impl Trait because turbofish is required. https://github.com/diesel-rs/diesel/blob/d3b1ce1db3bc4c419b661a3ad1f4ca5e3b85e20d/diesel/src/sqlite/connection/raw.rs#L93 …
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.