cargo fmt
This commit is contained in:
parent
4ab251b0a2
commit
c38b4b601d
34
src/lib.rs
34
src/lib.rs
|
@ -90,13 +90,12 @@ pub trait NumOps<Rhs = Self, Output = Self>:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, Rhs, Output> NumOps<Rhs, Output> for T
|
impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
|
||||||
where
|
|
||||||
T: Add<Rhs, Output = Output>
|
T: Add<Rhs, Output = Output>
|
||||||
+ Sub<Rhs, Output = Output>
|
+ Sub<Rhs, Output = Output>
|
||||||
+ Mul<Rhs, Output = Output>
|
+ Mul<Rhs, Output = Output>
|
||||||
+ Div<Rhs, Output = Output>
|
+ Div<Rhs, Output = Output>
|
||||||
+ Rem<Rhs, Output = Output>,
|
+ Rem<Rhs, Output = Output>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,22 +104,14 @@ where
|
||||||
///
|
///
|
||||||
/// This is automatically implemented for types which implement the operators.
|
/// This is automatically implemented for types which implement the operators.
|
||||||
pub trait NumRef: Num + for<'r> NumOps<&'r Self> {}
|
pub trait NumRef: Num + for<'r> NumOps<&'r Self> {}
|
||||||
impl<T> NumRef for T
|
impl<T> NumRef for T where T: Num + for<'r> NumOps<&'r T> {}
|
||||||
where
|
|
||||||
T: Num + for<'r> NumOps<&'r T>,
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The trait for references which implement numeric operations, taking the
|
/// The trait for references which implement numeric operations, taking the
|
||||||
/// second operand either by value or by reference.
|
/// second operand either by value or by reference.
|
||||||
///
|
///
|
||||||
/// This is automatically implemented for types which implement the operators.
|
/// This is automatically implemented for types which implement the operators.
|
||||||
pub trait RefNum<Base>: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base> {}
|
pub trait RefNum<Base>: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base> {}
|
||||||
impl<T, Base> RefNum<Base> for T
|
impl<T, Base> RefNum<Base> for T where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base> {}
|
||||||
where
|
|
||||||
T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The trait for types implementing numeric assignment operators (like `+=`).
|
/// The trait for types implementing numeric assignment operators (like `+=`).
|
||||||
///
|
///
|
||||||
|
@ -130,9 +121,8 @@ pub trait NumAssignOps<Rhs = Self>:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, Rhs> NumAssignOps<Rhs> for T
|
impl<T, Rhs> NumAssignOps<Rhs> for T where
|
||||||
where
|
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>
|
||||||
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,22 +130,14 @@ where
|
||||||
///
|
///
|
||||||
/// This is automatically implemented for types which implement the operators.
|
/// This is automatically implemented for types which implement the operators.
|
||||||
pub trait NumAssign: Num + NumAssignOps {}
|
pub trait NumAssign: Num + NumAssignOps {}
|
||||||
impl<T> NumAssign for T
|
impl<T> NumAssign for T where T: Num + NumAssignOps {}
|
||||||
where
|
|
||||||
T: Num + NumAssignOps,
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The trait for `NumAssign` types which also implement assignment operations
|
/// The trait for `NumAssign` types which also implement assignment operations
|
||||||
/// taking the second operand by reference.
|
/// taking the second operand by reference.
|
||||||
///
|
///
|
||||||
/// This is automatically implemented for types which implement the operators.
|
/// This is automatically implemented for types which implement the operators.
|
||||||
pub trait NumAssignRef: NumAssign + for<'r> NumAssignOps<&'r Self> {}
|
pub trait NumAssignRef: NumAssign + for<'r> NumAssignOps<&'r Self> {}
|
||||||
impl<T> NumAssignRef for T
|
impl<T> NumAssignRef for T where T: NumAssign + for<'r> NumAssignOps<&'r T> {}
|
||||||
where
|
|
||||||
T: NumAssign + for<'r> NumAssignOps<&'r T>,
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! int_trait_impl {
|
macro_rules! int_trait_impl {
|
||||||
($name:ident for $($t:ty)*) => ($(
|
($name:ident for $($t:ty)*) => ($(
|
||||||
|
|
|
@ -206,11 +206,7 @@ empty_trait_impl!(Unsigned for usize u8 u16 u32 u64);
|
||||||
#[cfg(has_i128)]
|
#[cfg(has_i128)]
|
||||||
empty_trait_impl!(Unsigned for u128);
|
empty_trait_impl!(Unsigned for u128);
|
||||||
|
|
||||||
impl<T: Unsigned> Unsigned for Wrapping<T>
|
impl<T: Unsigned> Unsigned for Wrapping<T> where Wrapping<T>: Num {}
|
||||||
where
|
|
||||||
Wrapping<T>: Num,
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn unsigned_wrapping_is_unsigned() {
|
fn unsigned_wrapping_is_unsigned() {
|
||||||
|
|
Loading…
Reference in New Issue