rust - 类型不匹配 : expected somestruct<_, _> 得到了一些结构<R,F>

标签 rust type-inference type-mismatch

谁能解释一下这个错误是什么意思?这实际上是相同的结构。 它是否无法以某种方式推断出 R 或 F 并以这种方式报告?

src/demo.rs:113:51: 113:65 error: mismatched types:
 expected `&mut gfx_debug_draw::debug_renderer::DebugRenderer<_, _>`,
    found `&mut gfx_debug_draw::debug_renderer::DebugRenderer<R, F>`
(expected struct `gfx_debug_draw::debug_renderer::DebugRenderer`,
    found a different struct `gfx_debug_draw::debug_renderer::DebugRenderer`) [E0308]
src/demo.rs:113                 self.skeleton.draw(&global_poses, debug_renderer, settings.draw_labels);
                                                                  ^~~~~~~~~~~~~~

违规行在这里: https://github.com/PistonDevelopers/skeletal_animation_demo/blob/master/src/demo.rs#L113 debug_renderer 在这里定义: https://github.com/PistonDevelopers/skeletal_animation_demo/blob/master/src/demo.rs#L97 这些类型来自此处的 impl: https://github.com/PistonDevelopers/skeletal_animation_demo/blob/master/src/demo.rs#L43

函数本身在这里: https://github.com/PistonDevelopers/skeletal_animation/blob/master/src/skeleton.rs#L66-L70

Rust 1.5 和 1.3,同样的错误。

最佳答案

看起来您的项目使用了两个不同版本的gfx_debug_draw(因此找到了一个不同的结构gfx_debug_draw::debug_renderer::DebugRenderer。它是相同的结构,但来自不同的同一个包的多个版本。),可能是因为您在 Cargo.toml 中指定了一个版本,而您的一个依赖项指定了另一个版本。你应该检查你的 Cargo.lock 看看是否是真的,然后确保你在所有地方都使用相同版本的箱子。

关于rust - 类型不匹配 : expected somestruct<_, _> 得到了一些结构<R,F>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32903119/

相关文章:

rust - 为什么借用仍然保留在 if let 的 else block 中?

rust - 为什么即使设置了 RUST_BACKTRACE=1,当我的程序出现段错误时我也得不到回溯?

scala - Scala 匿名函数中的模式匹配

F# Seq.head & Seq.tail 类型与自定义类型不匹配

带有专用 txt 文件的 Java 输入不匹配异常

closures - 存储捕获返回值的闭包时存在冲突的生命周期要求

windows - rust :来自 “file repository”结构的怪异行为

haskell - 推断 if ... then ... else 奇怪的行为

generics - 当组合泛型和非泛型类时,类型变量转义作用域

Swift:面向协议(protocol)的方法期间出错。错误:无法将类型 'I.Job' 的返回表达式转换为返回类型 'ActualJob'