gfx
gfx copied to clipboard
Auto-generate `empty` backend implementations
Apparently, this is trivial with proc macros like https://crates.io/crates/mock_derive
actually, it turns out to require nightly
I think proc-macros are stable enough to use nowadays. Would a solution like mockall work?
@GabrielMajeri no idea. Worth a try, perhaps?
I've looked into it.
It has some bugs which will be fixed, but the major issue with it is that it would require us to keep two copies of each trait in the hal crate:
- the original, documented and exposed by the crate
- the other textual copy would be inside a
mock!macro, because that's what's required to mock a trait on a struct:
pub trait Device<B: Backend> { /* ... */ }
mock! {
pub FakeDevice {}
trait Device<B: Backend> {
/* copy & paste, except for docs and function bodies */
}
}
I think it would just lead to more maintenance overhead.