comprehensive-rust icon indicating copy to clipboard operation
comprehensive-rust copied to clipboard

`anyhow`: Remove `ReadUsernameError::IoError`

Open ilyagr opened this issue 2 years ago • 3 comments

As far as I understand, the example with the anyhow example does not use its special IoError anymore, unlike the previous example with just thiserror.

I think this should be made clear. I considered just adding a // Now unused comment, but I think ti's clearer to just remove the unused code.

ilyagr avatar Dec 23 '22 21:12 ilyagr

As far as I understand, the example with the anyhow example does not use its special IoError anymore, unlike the previous example with just thiserror.

Oh, are you saying that calling .context(...) converts the type away from io::Error? I had not thought of that...

mgeisler avatar Dec 23 '22 22:12 mgeisler

Exactly.

Tangentially related: https://github.com/dtolnay/thiserror/issues/214

ilyagr avatar Dec 23 '22 22:12 ilyagr

To be more precise, I think the io:Error is wrapped into anyhow::Error as opposed to ReadUsernameError::IoError. I'm not an expert though.

ilyagr avatar Dec 23 '22 22:12 ilyagr

Thanks, I finally tested this and you're spot on with your explanation :smile:

mgeisler avatar Jan 05 '23 14:01 mgeisler