@jonhoo@rustlang Two intermediate / advanced topics that I don't remember you covering (but I might have just missed or might be too tool-specific): fuzzing (including detecting bugs in unsafe code with e.g. ASan) and wrapping C++ APIs (maybe using bindgen, ritual, or cxx).
@kastnerkyle This approach has also served me well. The only major time it breaks is when a super-class of a super-class of a small utility decides to read /dev/urandom in its constructor. (e.g. gym.spaces.Spaces)
@jonhoo@BRIAN_____ Yeah, I expect it varies depending on the trait. The enum_dispatch method might be able to avoid a pointer lookup (if enum value is loaded) and indirect branch (if there are few trait implementations), but it's not clear which one would result in better inlining and icache usage.
@jonhoo@BRIAN_____ Yeah, there's definitely a tradeoff. This should perform better, since it avoids the dynamic dispatch altogether, but it requires the annotation to be applied to the trait definition, since otherwise it doesn't know what to generate. https://t.co/fmcybyWhWy does the opposite.
@jonhoo@BRIAN_____ Actually, reading through the code again, enum_dispatch actually implements the trait for the dispatch type (https://t.co/SIQZHI5r4o). What you've done here is closer to what the trait_enum crate does, although it implements Deref instead of AsRef (https://t.co/UCfxwxpnD1).
@jonhoo@BRIAN_____ Reading through your code on the playground, I think this is the same general idea as https://t.co/2te6Uu0vET. I could be wrong though.