【发布时间】:2023-03-05 20:00:01
【问题描述】:
我有一些代码在本地定义类型并使用类型推断时绝对正确:
但问题是它在游戏的更新循环中加载字体。所以我想做的是将glyph 存储为Game 结构的一部分并让它推断类型
https://github.com/RustyRails/rustoid
即使 Game 结构具有正确的类型推断,代码也不会编译并出现错误:
src/main.rs:89:13: 89:17 error: type mismatch resolving `<object::gfx_graphics::back_end::GfxGraphics<'_, gfx_device_gl::Resources, gfx_device_gl::command::CommandBuffer> as graphics::graphics::Graphics>::Texture == <T as graphics::character::CharacterCache>::Texture`:
expected struct `gfx_texture::Texture`,
found associated type [E0271]
src/main.rs:89 text(red, 32, "Hello World", &mut self.glyphs, transform, graphics)
^~~~
我在这里错过了什么?
【问题讨论】:
-
请生成MCVE 并在此处发布该代码。作为理解问题的主要方式的非现场资源链接不适用于 Stack Overflow,但您可以包含该链接作为进一步的信息。
-
@heptic 你能提供一个 MCVE 吗?
标签: rust type-inference