Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Generic callback function - clunky version
Ref:
Rust does not allow a generic type parameter in a function parameter. At least not yet.
I need to do that, though, so here's a solution involving Box, RefCell, and run-time borrow().
It works, but is a bit clunky. Suggestions?
I tried using just RefCell
, which, like Box
, takes ownership of its content. But RefCell<&dyn mut Any>
doesn't work.
(Use case: passing a mutable link to a MySQL connection into something that uses it repeatedly.)
1 post - 1 participant
🏷️ Rust_feed