Closed Bubbler-4 closed 3 years ago
There used to be a Language
trait, right? What's wrong with making instances of Language
and putting them in a Vec
just once to access everywhere?
It's slightly harder than that because of interpret<T>
. Some quick search gives that I'll need something like anymap
to collect them (which means I won't need a macro after all).
Could using dynamic dispatch (something like static LANGS: Vec<dyn Language> = vec![Deafish{}, S10K{}, ...];
) work?
Edit: Never mind, that doesn't work, but would using &dyn LangWriter
work instead to get rid of T
? Language
could just be a struct that you make instances of for each language instead of a trait to be implemented.
Currently, adding a language requires editing four places in
lang/mod.rs
and adds five lines (mod
declaration and adding at four places). It would be better (and less error-prone if we get more langs) if a macro is used to allow editing in only one place.