`assert_eq` for a `Vec<Box<dyn SomeTrait>>`?

I have the following struct and would like to compare its instances in unit tests:

#[derive(PartialEq, Debug)]
pub struct InlineSequence {
    pub inline_vec: Vec<Box<dyn Inline>>,
}

I have found a solution but it seems quite complex: rust - How to test for equality between trait objects? - Stack Overflow

I’m wondering if there is a simpler solution.

Not really, unless you include crates as simpler.

2 Likes

No that’s great, thanks! Link: https://crates.io/crates/dyn_partial_eq/

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.