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

Function downcast_mut

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

Source from the content-addressed store, hash-verified

21
22#[test]
23fn downcast_mut() {
24 let mut report = create_report();
25 assert!(report.contains::<RootError>());
26
27 assert!(!report.contains::<AttachmentA>());
28 report = report.attach_opaque(AttachmentA(10));
29 assert!(report.contains::<AttachmentA>());
30
31 let attachment = report
32 .downcast_mut::<AttachmentA>()
33 .expect("Attachment not found");
34 attachment.0 += 10;
35
36 let attachment = report
37 .downcast_ref::<AttachmentA>()
38 .expect("Attachment not found");
39 assert_eq!(attachment.0, 20);
40}
41
42#[test]
43fn downcast_mut_deep() {

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