Added checks to ZeroToOne division

Refs #120
This commit is contained in:
Jonathan Johnson 2023-12-31 07:50:26 -08:00
parent 0fb93c7be8
commit d739ef1b79
No known key found for this signature in database
GPG key ID: A66D6A34D6620579

View file

@ -1289,6 +1289,9 @@ impl MulAssign for ZeroToOne {
impl Div for ZeroToOne {
type Output = Self;
/// Divides `self` by `rhs`.
///
/// If `rhs` is `0.`, the result will be [`ZeroToOne::ONE`].
fn div(mut self, rhs: Self) -> Self::Output {
self /= rhs;
self
@ -1296,6 +1299,9 @@ impl Div for ZeroToOne {
}
impl DivAssign for ZeroToOne {
/// Divides `self` by `rhs`.
///
/// If `rhs` is `0.`, the result will be [`ZeroToOne::ONE`].
fn div_assign(&mut self, rhs: Self) {
self.checked_div(rhs);
}
@ -1306,6 +1312,8 @@ impl Div<f32> for ZeroToOne {
/// Divides `self` by `rhs`.
///
/// If `rhs` is `0.`, the result will be [`ZeroToOne::ONE`].
///
/// # Panics
///
/// This function panics if `rhs` is not a number.
@ -1318,6 +1326,8 @@ impl Div<f32> for ZeroToOne {
impl DivAssign<f32> for ZeroToOne {
/// Divides `self` by `rhs`.
///
/// If `rhs` is `0.`, the result will be [`ZeroToOne::ONE`].
///
/// # Panics
///
/// This function panics if `rhs` is not a number.