Por que recebo o erro "a característica` Foo` não está implementada para `& mut T`" ", apesar de T implementar a característica?
Eu tenho esta fonte:
pub fn draw<G, C>(&self, font: &mut C, draw_state: &DrawState, transform: Matrix2d, g: &mut G)
where
C: CharacterCache,
G: Graphics<Texture = <C as CharacterCache>::Texture>,
{
self.properties.draw(
self.text.as_str(),
&mut font,
&draw_state,
transform,
g,
);
}
E o erro
the trait bound `&mut C: graphics::character::CharacterCache` is not satisfied
(the trait `graphics::character::CharacterCache` is not implemented for `&mut C`)
O único aspecto deC
que é definido é que ele implementaCharacterCache
, mas o erro diz o contrário.
DrawState
, Matrix2d
, CharacterCache
e suas implementações,Texture
e self.properties (Text
) são fornecidos pela biblioteca de gráficos Piston 2d. Deve haver algo sobre traços em geral que estou entendendo mal.
oText::draw
assinatura da função:
fn draw<C, G>(
&self,
text: &str,
cache: &mut C,
draw_state: &DrawState,
transform: Matrix2d,
g: &mut G,
) where
C: CharacterCache,
G: Graphics<Texture = C::Texture>,