我是 Rust 的新手,发现了一些我无法理解的情况。当我写下 时,
fn main() {
('a'..'z').all(|_| true);
}
编译器报告了一个错误:
error[E0599]: no method named `all` found for type `std::ops::Range<char>` in the current scope
--> src/main.rs:2:16
|
2 | ('a'..'z').all(|_| true)
| ^^^
|
= note: the method `all` exists but the following trait bounds were not satisfied:
`std::ops::Range<char> : std::iter::Iterator`
当我将其更改为
fn main() {
(b'a'..b'z').all(|_| true);
}
编译通过了。
这里发生了什么?当 Rust 说 该方法…已存在但未满足以下特性限制
时,它是指什么?