Rust 1.8.0 每晚编译器的 Rustboot 错误

标签 rust

我正在尝试修复 Rustboot,以便它可以使用 i686-unknown-linux-gnu 在 Rust 1.8.0 中每晚构建和运行。我有两个似乎无法修复的主要错误,就是这些错误:

main.rs:50:5: 54:6 error: the trait `core::iter::Iterator` is not implemented for the type `IntRange` [E0277]
main.rs:50     for i in range(0, 80 * 25) {
main.rs:51         unsafe {
main.rs:52             *((0xb8000 + i * 2) as *mut u16) = (background as u16) << 12;

main.rs:52:15: 52:44 error: the type of this value must be known in this context
main.rs:52             *((0xb8000 + i * 2) as *mut u16) = (background as u16) << 12;

关于为什么会发生这种情况以及我该如何解决的任何想法?

Rustboot main.rs 文件的链接:http://pastebin.com/wyDywYN8

最佳答案

IntRange 没有实现core::iter::Iterator,自然不能用在for循环中。 i 类型的错误是相关的 - 因为 IntRange 没有实现 Iterator,所以当它作为一个使用时,它的类型项目未知。

您应该实现 Iterator 而不是提供 next() 作为固有方法:

use core::iter::Iterator;

impl Iterator for IntRange {
    type Item = i32;

    fn next(&mut self) -> Option<i32> {
        // your implementation
    }
}

然而,这可能还不够,因为 for 循环也依赖于 Option,但我现在不记得它是 lang 项还是通过完整路径查找。

关于Rust 1.8.0 每晚编译器的 Rustboot 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35394358/

相关文章:

rust - 使用静态函数实现特征对特征

typescript - 用于right = | _a |的Rust泛型类型实现| b | b

rust - 为什么 read_line 不改变它的论点?

rust - 如何在另一个闭包中捕获一个闭包?

rust - 如何在 Rust 中干净地实现 "waterfall"逻辑

visual-studio-code - 如何从 VS Code 而不是通过命令行创建一个新的 Rust 项目?

rust - 克隆&[u32]至[u32]

rust - 用 Rust 解析二进制协议(protocol)的最佳方法是什么

rust - 有没有办法不显示非蛇案例标识符的警告?

rust - 我可以在 Rocket 中使用 async fn 作为处理程序吗?