I’ve been working on an emulator for awhile now and am very close to finishing the cpu part and am having a bit of trouble with a cryptic lifetime error.
This is a 68k cpu emulator based on r68k and Musashi. r68k had everything pretty much done just extracted everything and refactored some stuff to look cleaner. Main change is I pass a Bus trait everywhere so the user (myself) only has to implement the Bus trait (should be like a memory map read/write).
My error is when trying to add the opcode functions as pointers into the 64k opcode table I’m getting “expected concrete lifetime, found bound lifetime parameter” on all my opcode additions.
Here is an example of the error.
All code is included at https://github.com/mattbettcher/m68k
I know I’m using the feature ‘universal_impl_trait’, I feel that makes the code look cleaner. I did try to add explicit lifetimes everywhere, but still got the same error, so I don’t think it’s that.
Before I throw in the towel on this Trait Object as an interface I’d love to hear any help or suggestions. My only alternative is callbacks? or forget the separate crate and just hard code the cpu in. My hope was for something others could use again.
Here is my current toolchain.