Using enums for dynamic polymorphism in Rust
问题 When one already knows all the finite number of types involved in some code which needs dynamic polymorphism, using enum can be better for performances compared to using Box since the latter uses dynamic memory allocation and you'll need to use trait objects which have virtual function call as well. That said, compared to the equivalent code in C++ using std::variant and std::visit , looks like Rust in this scenario has more boilerplate coding involved, at least for me (I have not yet learned