3 ms·
The example you posted is very interesting as it used both a visitor and ADTs. It seems the need for the Visitor comes from the generics in this case? Probably
by brabel 1y ago
The example you posted is very interesting as it used both a visitor and ADTs. It seems the need for the Visitor comes from the generics in this case? Probably a Rust specific limitation. I don’t understand why you mention exhaustiveness though, it’s obviously easy have comprehensive or partial matching with ADT.
- cyberax 1y agoNo. The code can be rewritten without visitors using iterators for traversal, for example). But it'll look badly. Visitors in the linked example are real classic visitors. The code _within_ the visitor methods, of course, uses pattern matching, but the pattern itself is not materially different from C++. Exhaustiveness checking for pattern matching is also "best effort" for complex matching.