Hello! Is there some way to find out the ErrorKind of a std::io::Error by pattern matching?
match res { // res is of the type std::result::Result<T, std::io::Error>
Err( /* what to put here */ ) => { /* do something for the Err of particular ErrorKind */ },
_ => { /* do something for all the other cases including the Ok variant*/ }
}
If this is not possible, then what is the best way to achieve the same?
Thanks
pub fn my_func() {
let res = can_fail();
match res {
Err(err) if err.kind() == ErrorKind::WouldBlock => {
// would block error
},
_ => {
// other
},
}
}