MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / chain

Function chain

crates/core/tests/tests.rs:793–814  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

791
792#[test]
793fn 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]
817fn chain_on_error_with_source() {

Callers

nothing calls this directly

Calls 6

msgFunction · 0.85
chainMethod · 0.80
TestErrorClass · 0.70
contextMethod · 0.45
unwrapMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected