Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::error::Error::source documentation example uses deprecated description method #70278

Closed
olehmisar opened this issue Mar 22, 2020 · 1 comment

Comments

@olehmisar
Copy link

https://doc.rust-lang.org/std/error/trait.Error.html#method.source.

The documentation example contains the deprecated std::error::Error::description method in the main function:

fn main() {
    match get_super_error() {
        Err(e) => {
            println!("Error: {}", e.description());  // <----------- HERE IT IS
            println!("Caused by: {}", e.source().unwrap());
        }
        _ => println!("No error"),
    }
}

This is probably a mistake as get_super_error returns a struct that implements the std::fmt::Display trait which should be used instead of the deprecated std::error::Error::description method. So, this:

println!("Error: {}", e.description());

...should be written like this:

println!("Error: {}", e);
@jonas-schievink
Copy link
Contributor

This was fixed by #70218

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants