refactor(tokens): replace Token trait with an enum
Using a trait was a poor fit for the token types because they share so much data and behaviour. Traits can have default method implementations but that falls down when those implementations need to access non-trait members such as data. An enum works much better, with common behaviour pulled out to helper structs. One snag I hit was that I ended up with circular references that caused the compiler to complain. The only way I could see to work round this was to stop holding direct references as use a memory arena instead. So where there were Rc<RefCell<Token>> we now use ids which are actually just indices into a big vec of tokens. This should also make it straightforward to handle the propagation of edits through child token types.
Loading
Please register or sign in to comment