Location
Derive macros for Ord and PartialOrd.
Summary
The derive macros for Ord and PartialOrd do not specify what the order of precedence it generates in the resulting implementation. This order matters, and makes reordering fields on a type with this derive a semver-incompatible breaking change.
Examples
#[derive(PartialEq, Eq, PartialOrd, Ord)]
pub struct MyStruct {
field_1: u32,
field_2: i32,
}
Does field_1 take precedence over field_2 when comparing two MyStructs?
#[derive(PartialEq, Eq, PartialOrd, Ord)]
pub enum MyEnum {
Variant_1 {
field_1: u32,
field_2: i32,
},
Variant_2 {
field_1: i32,
field_2: u32,
}
Variant_3(MyStruct),
}
Do all Variant_1 come before or after Variant_2?
Location
Derive macros for Ord and PartialOrd.
Summary
The derive macros for Ord and PartialOrd do not specify what the order of precedence it generates in the resulting implementation. This order matters, and makes reordering fields on a type with this derive a semver-incompatible breaking change.
Examples
Does
field_1take precedence overfield_2when comparing twoMyStructs?Do all
Variant_1come before or afterVariant_2?