Skip to content
Commit e7c2efe3 authored by Phil Booth's avatar Phil Booth
Browse files

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.
parent 65430ece
Loading
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment