@@ -46,6 +46,14 @@ pub trait Euclid: Sized + Div<Self, Output = Self> + Rem<Self, Output = Self> {
46
46
/// assert_eq!(Euclid::rem_euclid(&-a, &-b), 1);
47
47
/// ```
48
48
fn rem_euclid ( & self , v : & Self ) -> Self ;
49
+
50
+ /// Returns both the euclidian division quotien and remainer
51
+ ///
52
+ /// By default, it internaly calls both `Euclid::div_euclid` and `Euclid::rem_euclid`,
53
+ /// but it can be overwritten in order to implement some optimization.
54
+ fn div_with_rem_euclid ( & self , v : & Self ) -> ( Self , Self ) {
55
+ ( self . div_euclid ( v) , self . rem_euclid ( v) )
56
+ }
49
57
}
50
58
51
59
macro_rules! euclid_forward_impl {
@@ -174,6 +182,14 @@ pub trait CheckedEuclid: Euclid {
174
182
/// Finds the euclid remainder of dividing two numbers, checking for underflow, overflow and
175
183
/// division by zero. If any of that happens, `None` is returned.
176
184
fn checked_rem_euclid ( & self , v : & Self ) -> Option < Self > ;
185
+
186
+ /// Returns both the checked euclidian division quotien and remainer
187
+ ///
188
+ /// By default, it internaly calls both `Euclid::div_euclid` and `Euclid::rem_euclid`,
189
+ /// but it can be overwritten in order to implement some optimization.
190
+ fn checked_div_with_rem_euclid ( & self , v : & Self ) -> Option < ( Self , Self ) > {
191
+ Some ( ( self . checked_div_euclid ( v) ?, self . checked_rem_euclid ( v) ?) )
192
+ }
177
193
}
178
194
179
195
macro_rules! checked_euclid_forward_impl {
0 commit comments