We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Debug
1 parent 6e4fc47 commit 935ed6bCopy full SHA for 935ed6b
src/lib.rs
@@ -776,6 +776,7 @@ macro_rules! quick_error {
776
}
777
778
779
+#[derive(Debug)]
780
pub struct Context<X, E>(pub X, pub E);
781
782
pub trait ResultExt<T, E> {
@@ -999,4 +1000,14 @@ mod test {
999
1000
assert_eq!(format!("{}", parse_int("12.5").unwrap_err()),
1001
r#"Int error "12.5": invalid digit found in string"#);
1002
1003
+
1004
+ #[test]
1005
+ fn debug_context() {
1006
+ fn parse_int(s: &str) -> i32 {
1007
+ s.parse().context(s).unwrap()
1008
+ }
1009
+ assert_eq!(parse_int("12"), 12);
1010
+ assert_eq!(format!("{:?}", "x".parse::<i32>().context("x")),
1011
+ r#"Err(Context("x", ParseIntError { kind: InvalidDigit }))"#);
1012
1013
0 commit comments