Why is assignment of a struct allowed and comparison not
Ziggit
Why is assignment of a struct allowed and comparison not
Well… the title of this topic is already self-explanatory. Why can’t we (always) compare structs while assigning is always allowed? const b: AnyStruct = .init(...); const a: AnyStruct = b; // always allowed. const eql: bool = (a == b); // not always allowed. error: operator == not allowed for type I know this is because the internal layout of a struct. But in my mind it goes like: “if Zig can copy it should also be able to compare”.
0 comments
No comments yet.