I've got this function that I want to test:
pub fn run(config: Config) -> Result<(), Box<dyn Error>> {
let contents = fs::read_to_string(config.filename)?;
// -- snip
Ok(())
}
And this test:
#[test]
fn error_for_missing_file() {
let error = run(Config {
query: String::from("query"),
filename: String::from("not_a_real_file.txt"),
})
.unwrap_err();
let kind = error.kind(); // no method named `kind` found for struct `Box<dyn std::error::Error>` in the current scope
// assert to follow
}
How can I get the ErrorKind from a Box?