In gfx-rs we have a Resources type with a bunch of associated types. Whatever works with gfx-rs in a backend-abstract way depends on
R: Resources bound.
Now, there is a problem when one wants to have explicit lifetimes for anything that depends on
R. Rust requires the bounds to also be applied to all associated types of
R, even if some of them are not used, and Rust is not able to derive this constraint. We end up with this boilerplate in the
R::Buffer: 'a, R::ArrayBuffer: 'a, R::Shader: 'a, R::Program: 'a, R::FrameBuffer: 'a, R::Surface: 'a, R::Texture: 'a, R::Sampler: 'a,
This file in
gfx_scene has lots of examples, because this dependency propagates upwards, thus hammering our ability to build high-level abstractions.
Note-1: this has been reported on reddit earlier.
Note-2: Complaint from Layl - our user at the time - on IRC:
that really is not an acceptable solution
if every time I need to have a reference stored to something in gfx, I need to bring 8 bounds along
Note-3: the problem is not limited to our
gfx::Resources, it’s just given as an example.