Using assert_eq! to test returned structures

Hello again! :slight_smile:

I'm trying to write a test for a function that returns a value of type io::Result<Vec<OptionProperties>>

But I don't know express the literal values returned by Vec to use as the second parameter of assert_eq!(). I know how if it's just a vector, but not a structure.

    pub struct Value {
        pub primary: String,
        pub attributes: Vec<String>,

    pub struct OptionProperties {
        pub option: String,
        pub value: Value,

You need to derive PartialEq to use a structure in an assert_eq!.

1 Like

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.