Rust can be not so boring languge as Some(may think)

Today is Saturday, so we can stop fighting with the borrow checker over the weekend and have a little laugh, because rustc is a humorous. Some trait in some crate got changed, so Rust compiler gave me an error but also gave me a help:

help: change the output type to match the trait
   |
12 -     fn main_load(&self) -> Result<String, String> {
12 +     fn main_load(&self) -> Result<String, Box<(dyn std::error::Error + 'static)>> {
   |

Oh, great, thank you Rust compiler, and applied the help:
But what???

warning: unnecessary parentheses around type
  --> rust/upload.rs:12:47
   |
12 |     fn main_load(&self) -> Result<String, Box<(dyn std::error::Error + 'static)>> {
   |                                               ^                               ^
   |
   = note: `#[warn(unused_parens)]` (part of `#[warn(unused)]`) on by default
help: remove these parentheses
   |
12 -     fn main_load(&self) -> Result<String, Box<(dyn std::error::Error + 'static)>> {
12 +     fn main_load(&self) -> Result<String, Box<dyn std::error::Error + 'static>> {
   |

Did you check me on a knowledge of Rust syntax, or just a little joking?

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.