MCPcopy Create free account
hub / github.com/hashintel/hash / downcast_ref

Function downcast_ref

libs/error-stack/tests/test_downcast.rs:8–20  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6
7#[test]
8fn downcast_ref() {
9 let mut report = create_report();
10 assert!(report.contains::<RootError>());
11
12 assert!(!report.contains::<AttachmentA>());
13 report = report.attach_opaque(AttachmentA(10));
14 assert!(report.contains::<AttachmentA>());
15
16 let attachment = report
17 .downcast_ref::<AttachmentA>()
18 .expect("Attachment not found");
19 assert_eq!(attachment.0, 10);
20}
21
22#[test]
23fn downcast_mut() {

Callers

nothing calls this directly

Calls 4

AttachmentAClass · 0.85
create_reportFunction · 0.70
attach_opaqueMethod · 0.45
expectMethod · 0.45

Tested by

no test coverage detected