tim-harding / soa-rs

An SoA library for Rust
MIT License
113 stars 2 forks source link

Support fields with types that do not implement PartialEq #10

Closed PPakalns closed 7 months ago

PPakalns commented 7 months ago

Test that doesn't pass:

#[test]
fn field_type_without_partial_eq() {
    // Type that doesn't implement PartialEq
    struct TypeWithoutPartialEq {
        foo: u8,
    }

    #[derive(Soars)]
    struct Example {
        a: TypeWithoutPartialEq,
    }
    let arr = soa![Example {
        a: TypeWithoutPartialEq { foo: 1 }
    }];
    assert_eq!(arr.get(0).unwrap().a.foo, 1);
}

If PartialEq derives are added, then this test passes. It shouldn't be required.

Tried to fix this in https://github.com/tim-harding/soa-rs/pull/8/files , but pull request was closed even if the existing PartialEq implementation in derive macro for #itemRef was made conditional (kept the same) based on soa_derive.

This heavily limits what types can be stored in Soa.

tim-harding commented 7 months ago

This clarifies the issue. I am publishing 0.4.0 that passes this test.