【发布时间】:2022-08-17 00:51:51
【问题描述】:
到目前为止,我已经编写了一个简单的代码,它并没有做太多的事情。 编译器建议我添加一个特征绑定步骤。但是在添加它之后,编译器给了我一个错误。
use std::fmt::Display;
use std::ops::Range;
use std::iter::Step;
fn main() {
display(0..10);
}
fn display<T: Display + Step>(range: Range<T>) {
for i in range {
print!(\"{i} \");
}
println!();
}
错误 :
Compiling playground v0.0.1 (/playground)
error[E0658]: use of unstable library feature \'step_trait\': recently redesigned
--> src/main.rs:3:5
|
3 | use std::iter::Step;
| ^^^^^^^^^^^^^^^
|
= note: see issue #42168 <https://github.com/rust-lang/rust/issues/42168> for more information
= help: add `#![feature(step_trait)]` to the crate attributes to enable
error[E0658]: use of unstable library feature \'step_trait\': recently redesigned
--> src/main.rs:9:25
|
9 | fn display<T: Display + Step>(range: Range<T>) {
| ^^^^
|
= note: see issue #42168 <https://github.com/rust-lang/rust/issues/42168> for more information
= help: add `#![feature(step_trait)]` to the crate attributes to enable
For more information about this error, try `rustc --explain E0658`.
error: could not compile `playground` due to 2 previous errors
标签: rust