-
Notifications
You must be signed in to change notification settings - Fork 172
Open
Description
页码与行数
- 代码清单7-9
- 第4-7行
文本或排版错误
暂无
代码错误
impl fmt::Display for ColoredString {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut input = &self.input.clone(); // 此处应该是let input = &self.input.clone();
try!(f.write_str(&self.compute_style())); // 此处应该是f.write_str(&self.compute_style())?;
try!(f.write_str(input)); // 此处应该是f.write_str(input)?;
try!(f.write_str("\x1B[0m")); // 此处应该是f.write_str("\x1B[0m")?;
Ok(())
}
}Rust版本
$ rustc -V
rustc 1.67.1 (d5a82bbd2 2023-02-07)
错误信息
warning: variable does not need to be mutable
--> src/color.rs:78:13
|
78 | let mut input = &self.input.clone();
| ----^^^^^
| |
| help: remove this `mut`
|
= note: `#[warn(unused_mut)]` on by default
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/color.rs:79:9
|
79 | try!(f.write_str(&self.compute_style()));
| ^^^
|
= note: `#[warn(deprecated)]` on by default
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/color.rs:80:9
|
80 | try!(f.write_str(input));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/color.rs:81:9
|
81 | try!(f.write_str("\x1B[0m"));
| ^^^Metadata
Metadata
Assignees
Labels
No labels