Merge #110
110: Check formatting in CI r=cuviper a=cuviper Co-authored-by: Josh Stone <cuviper@gmail.com>
This commit is contained in:
commit
38655c91c1
12
.travis.yml
12
.travis.yml
|
@ -1,15 +1,25 @@
|
||||||
language: rust
|
language: rust
|
||||||
|
sudo: false
|
||||||
rust:
|
rust:
|
||||||
- 1.8.0
|
- 1.8.0
|
||||||
- 1.15.0
|
- 1.15.0
|
||||||
- 1.20.0
|
- 1.20.0
|
||||||
|
- 1.26.0 # has_i128
|
||||||
|
- 1.31.0 # 2018!
|
||||||
- stable
|
- stable
|
||||||
- beta
|
- beta
|
||||||
- nightly
|
- nightly
|
||||||
sudo: false
|
|
||||||
script:
|
script:
|
||||||
- cargo build --verbose
|
- cargo build --verbose
|
||||||
- ./ci/test_full.sh
|
- ./ci/test_full.sh
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- name: "rustfmt"
|
||||||
|
rust: 1.31.0
|
||||||
|
before_script:
|
||||||
|
- rustup component add rustfmt
|
||||||
|
script:
|
||||||
|
- cargo fmt --all -- --check
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
on_success: never
|
on_success: never
|
||||||
|
|
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