I'm trying to work around a breaking change in winit. Winit used to just a library, but now it has a "framework", a trait that the caller must implement.
I'm stuck maintaining rend3-hp, a fork of non-longer-maintained rend3. I'm trying to keep the same API as rend3 while adapting it to use the new winit. It almost works. One compile error.
Here's the problem. Rend3's "framework" trait starts out like this:
pub trait App<T: 'static = ()> {
/// The handedness of the coordinate system of the renderer.
const HANDEDNESS: Handedness;
fn register_logger(&mut self) {
#[cfg(target_arch = "wasm32")]
console_log::init().unwrap();
...
Each application that uses rend3-framework has to provide a value for the const HANDEDNESS
. This worked fine until the latest "refactoring" over at winit. Now, winit has its own framework trait that has to be implemented by its user, which in this case is rend3.
pub trait ApplicationHandler {
/// Emitted when new events arrive from the OS to be processed.
Tying them together looks like this:
/// New Winit framework usage
type AppRef<'a> = &'a mut dyn App;
impl ApplicationHandler<AppRef<'static>> for Rend3ApplicationHandler<'_, AppRef<'_>> {
...
The trouble is that "dyn App". If a trait instantiation is dyn, it can't have constants. So the declaration of HANDEDNESS, above, won't work.
Making HANDEDNESS a const parameter to App would work nicely. But that breaks everything that calls rend3, which means I have to change three big programs plus about eight test cases.
So if there's any trick for working around this without changing App, it would help. I don't think there is one, but it's worth asking.
(This is why libraries shouldn't be made into "frameworks". Frameworks want to be in charge. They don't play well with other "frameworks")