| 791 | |
| 792 | #[test] |
| 793 | fn chain() { |
| 794 | let error = Error::msg("failure") |
| 795 | .context("uh oh") |
| 796 | .context(TestError(42)); |
| 797 | |
| 798 | let mut chain = error.chain(); |
| 799 | |
| 800 | let e = chain.next().unwrap(); |
| 801 | assert_eq!(e.to_string(), "TestError(42)"); |
| 802 | |
| 803 | let e = chain.next().unwrap(); |
| 804 | assert_eq!(e.to_string(), "uh oh"); |
| 805 | |
| 806 | let e = chain.next().unwrap(); |
| 807 | assert_eq!(e.to_string(), "failure"); |
| 808 | |
| 809 | assert!(chain.next().is_none()); |
| 810 | |
| 811 | for _ in 0..100 { |
| 812 | assert!(chain.next().is_none(), "`Chain` is a fused iterator"); |
| 813 | } |
| 814 | } |
| 815 | |
| 816 | #[test] |
| 817 | fn chain_on_error_with_source() { |