Skip to content

Commit c56a952

Browse files
committed
Make adding new fields to GcdResult a non-breaking change
1 parent a2d1cac commit c56a952

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,8 @@ pub struct GcdResult<T> {
10201020
pub gcd: T,
10211021
/// Coefficients such that: gcd(a, b) = c1*a + c2*b
10221022
pub c1: T, pub c2: T,
1023+
/// Dummy field to make sure adding new fields is not a breaking change.
1024+
seal: (),
10231025
}
10241026

10251027
/// Calculate greatest common divisor and the corresponding coefficients.
@@ -1040,7 +1042,7 @@ pub fn extended_gcd<T: Integer + NumRef>(a: T, b: T) -> GcdResult<T>
10401042

10411043
let _quotients = (t, s); // == (a, b) / gcd
10421044

1043-
GcdResult { gcd: old_r, c1: old_s, c2: old_t }
1045+
GcdResult { gcd: old_r, c1: old_s, c2: old_t, seal: () }
10441046
}
10451047

10461048
/// Find the standard representation of a (mod n).
@@ -1247,7 +1249,7 @@ fn test_lcm_overflow() {
12471249

12481250
#[test]
12491251
fn test_extended_gcd() {
1250-
assert_eq!(extended_gcd(240, 46), GcdResult { gcd: 2, c1: -9, c2: 47});
1252+
assert_eq!(extended_gcd(240, 46), GcdResult { gcd: 2, c1: -9, c2: 47, seal: () });
12511253
}
12521254

12531255
#[test]

0 commit comments

Comments
 (0)