Skip to content

Structure from C bindings without overloaded equal method throws C error when checking if array contains element #21

@ArtemkaKun

Description

@ArtemkaKun
pub type TSVector3f = C.TSVector3f

#[typedef]
struct C.TSVector3f {
    x Float32_t
    y Float32_t
    z Float32_t
}

mut random_positions := []tellusim.TSVector3f{cap: objects_count}

if random_positions.contains(random_cell_position)

throws

C compiler output:
/home/yuart/Projects/spawn/out.c: In function ‘Array_mG_tellusim___TSVector3f_eG__contains’:
/home/yuart/Projects/spawn/out.c:831:26: error: invalid operands to binary == (have ‘tellusim___TSVector3f’ {aka ‘TSVector3f’} and ‘tellusim___TSVector3f’ {aka ‘TSVector3f’})
  831 |                 if (item == value) {
      |                          ^~

error: C compiler failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions