Skip to content

Commit 3a2f01c

Browse files
committed
Add assert for error source to doc test
1 parent c9c164f commit 3a2f01c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//! ```
88
//! # use std::fs::read_to_string;
99
//! # use std::path::Path;
10+
//! # use std::io;
1011
//! #
1112
//! use fn_error_context::context;
1213
//!
@@ -16,9 +17,14 @@
1617
//! Ok(text.parse()?)
1718
//! }
1819
//!
20+
//! let error = parse_config("not-found").unwrap_err();
1921
//! assert_eq!(
20-
//! parse_config("not-found").unwrap_err().to_string(),
21-
//! "failed to parse config at `not-found`"
22+
//! error.to_string(),
23+
//! "failed to parse config at `not-found`",
24+
//! );
25+
//! assert_eq!(
26+
//! error.source().unwrap().downcast_ref::<io::Error>().unwrap().kind(),
27+
//! io::ErrorKind::NotFound,
2228
//! );
2329
//! ```
2430
//!

0 commit comments

Comments
 (0)