Skip to content

Commit 4f8f05f

Browse files
committed
feat(harness): Allow Box, Arc Cases
1 parent 3f6eb77 commit 4f8f05f

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

crates/libtest2-harness/src/case.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,44 @@ pub trait Case: Send + Sync + 'static {
1717
fn run(&self, state: &TestContext) -> Result<(), RunError>;
1818
}
1919

20+
impl Case for Box<dyn Case> {
21+
fn name(&self) -> &str {
22+
self.as_ref().name()
23+
}
24+
fn kind(&self) -> TestKind {
25+
self.as_ref().kind()
26+
}
27+
fn source(&self) -> Option<&Source> {
28+
self.as_ref().source()
29+
}
30+
fn exclusive(&self, state: &TestContext) -> bool {
31+
self.as_ref().exclusive(state)
32+
}
33+
34+
fn run(&self, state: &TestContext) -> Result<(), RunError> {
35+
self.as_ref().run(state)
36+
}
37+
}
38+
39+
impl Case for std::sync::Arc<dyn Case> {
40+
fn name(&self) -> &str {
41+
self.as_ref().name()
42+
}
43+
fn kind(&self) -> TestKind {
44+
self.as_ref().kind()
45+
}
46+
fn source(&self) -> Option<&Source> {
47+
self.as_ref().source()
48+
}
49+
fn exclusive(&self, state: &TestContext) -> bool {
50+
self.as_ref().exclusive(state)
51+
}
52+
53+
fn run(&self, state: &TestContext) -> Result<(), RunError> {
54+
self.as_ref().run(state)
55+
}
56+
}
57+
2058
/// Type of the test according to the [rust book](https://doc.rust-lang.org/cargo/guide/tests.html)
2159
/// conventions.
2260
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Default)]

0 commit comments

Comments
 (0)