If you know all possible types, you can use an Enum. @HadrienG made a comparison between the two in this reply, there are also crates that make the enum for you but I don't know if they work when it's not a trait you made.
Related Topics
Topic | Replies | Views | Activity | |
---|---|---|---|---|
Why cannot infer an appropriate lifetime for borrow expression? | 2 | 382 | July 28, 2020 | |
Need help with closure lifetimes
|
8 | 2534 | January 12, 2023 | |
Lifetimes are killing me | 10 | 757 | January 16, 2023 | |
Lifetimes issue while storing Rust async closure/functions for later invocation | 3 | 827 | March 2, 2021 | |
Can not understand why do not need clone for an async move block (example code from tower tutorial) | 3 | 337 | January 21, 2023 |