xdlol 0.0.0

Tests to study random data.
Documentation
//! Traits for internal use
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

use std::ops;
use num;

/// Arithmetic operations for Signed.
pub trait SignedArithmetic
where
    for<'a> Self: num::Integer
        + ops::Neg
        + ops::Add<Self, Output = Self>
        + ops::Sub<Self, Output = Self>
        + ops::Mul<Self, Output = Self>
        + ops::Div<Self, Output = Self>
        + ops::Rem<Self, Output = Self>
        + ops::Add<&'a Self, Output = Self>
        + ops::Sub<&'a Self, Output = Self>
        + ops::Mul<&'a Self, Output = Self>
        + ops::Div<&'a Self, Output = Self>
        + ops::Rem<&'a Self, Output = Self>
        + ops::AddAssign<Self>
        + ops::SubAssign<Self>
        + ops::MulAssign<Self>
        + ops::DivAssign<Self>
        + ops::RemAssign<Self>,
{
}

impl<T> SignedArithmetic for T
where
    for<'a> T: From<T>
        + num::Integer
        + ops::Neg
        + ops::Add<T, Output = T>
        + ops::Sub<T, Output = T>
        + ops::Mul<T, Output = T>
        + ops::Div<T, Output = T>
        + ops::Rem<T, Output = T>
        + ops::Add<&'a T, Output = T>
        + ops::Sub<&'a T, Output = T>
        + ops::Mul<&'a T, Output = T>
        + ops::Div<&'a T, Output = T>
        + ops::Rem<&'a T, Output = T>
        + ops::AddAssign<T>
        + ops::SubAssign<T>
        + ops::MulAssign<T>
        + ops::DivAssign<T>
        + ops::RemAssign<T>
        + ops::AddAssign<&'a T>
        + ops::SubAssign<&'a T>
        + ops::MulAssign<&'a T>
        + ops::DivAssign<&'a T>
        + ops::RemAssign<&'a T>,
{
}

/// Arithmetic operations for Unsigned.
pub trait UnsignedArithmetic
where
    for<'a> Self: num::Integer
        + ops::Add<Self, Output = Self>
        + ops::Sub<Self, Output = Self>
        + ops::Mul<Self, Output = Self>
        + ops::Div<Self, Output = Self>
        + ops::Rem<Self, Output = Self>
        + ops::Add<&'a Self, Output = Self>
        + ops::Sub<&'a Self, Output = Self>
        + ops::Mul<&'a Self, Output = Self>
        + ops::Div<&'a Self, Output = Self>
        + ops::Rem<&'a Self, Output = Self>
        + ops::AddAssign<Self>
        + ops::SubAssign<Self>
        + ops::MulAssign<Self>
        + ops::DivAssign<Self>
        + ops::RemAssign<Self>,
{
}

impl<T> UnsignedArithmetic for T
where
    for<'a> T: From<T>
        + num::Integer
        + ops::Add<T, Output = T>
        + ops::Sub<T, Output = T>
        + ops::Mul<T, Output = T>
        + ops::Div<T, Output = T>
        + ops::Rem<T, Output = T>
        + ops::Add<&'a T, Output = T>
        + ops::Sub<&'a T, Output = T>
        + ops::Mul<&'a T, Output = T>
        + ops::Div<&'a T, Output = T>
        + ops::Rem<&'a T, Output = T>
        + ops::AddAssign<T>
        + ops::SubAssign<T>
        + ops::MulAssign<T>
        + ops::DivAssign<T>
        + ops::RemAssign<T>
        + ops::AddAssign<&'a T>
        + ops::SubAssign<&'a T>
        + ops::MulAssign<&'a T>
        + ops::DivAssign<&'a T>
        + ops::RemAssign<&'a T>,
{
}

/// Arithmetic that will return `None` instead of overflow
pub trait CheckedArithmetic
    : num::Integer + num::CheckedAdd + num::CheckedSub + num::CheckedMul + num::CheckedDiv
    {
}

impl<T> CheckedArithmetic for T
where
    T: num::Integer + num::CheckedAdd + num::CheckedSub + num::CheckedMul + num::CheckedDiv,
{
}