Skip to content

Commit

Permalink
Run rustfmt and disable clippy in Travis (#39)
Browse files Browse the repository at this point in the history
Builds that fail for issues unrelated to pull requests are useless. This
PR gets the build passing again and hopefully it will stay that way.

One caveat is that clippy is now disabled in Travis builds. It is giving
me trouble running locally at the moment; I think the best approach is
to keep it disabled until it is incorporated into rustup.
  • Loading branch information
paholg authored Jun 25, 2018
1 parent a946893 commit 3ef45da
Show file tree
Hide file tree
Showing 19 changed files with 476 additions and 284 deletions.
33 changes: 17 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
language: rust
cache: cargo
sudo: false
rust:
- stable
- beta
- nightly
cache: cargo

notifications:
email:
recipients: paho@paholg.com

# fixme: re-enable rustfmt when it works
before_script:
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
- export TRAVIS_CARGO_NIGHTLY_FEATURE=""
# - test -x $HOME/.cargo/bin/rustfmt || cargo install rustfmt # Only install rustfmt if it's not there
matrix:
include:
- rust: nightly
before_script:
- rustup component add rustfmt-preview
script: |
cargo fmt --version &&
cargo fmt --all -- --check &&
cargo test --all-features
script:
# PATH=$PATH:~/.cargo/bin cargo fmt -- --write-mode=diff &&
- |
travis-cargo --only stable test &&
travis-cargo --only beta test &&
travis-cargo --only nightly test -- --features "test" &&
travis-cargo --only stable doc
script: |
cargo build &&
cargo test --features "approx quickcheck serde serde_test" &&
cargo doc
after_success:
- travis-cargo doc-upload
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && cargo publish --token ${CRATESIO_TOKEN}
- test $TRAVIS_PULL_REQUEST == "false" &&
test $TRAVIS_BRANCH == "master" &&
cargo publish --token ${CRATESIO_TOKEN}

env:
global:
Expand Down
12 changes: 5 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "dimensioned"
version = "0.6.0"
authors = ["Paho Lurie-Gregg <paho@paholg.com>"]
documentation = "http://paholg.com/dimensioned"
documentation = "https://docs.rs/dimensioned"
repository = "https://github.com/paholg/dimensioned"
readme = "README.md"
license = "MIT/Apache-2.0"
Expand All @@ -24,14 +24,12 @@ Never again should you need to specify units in a comment!"""
default = []
oibit = []
spec = []
test = ["clippy", "quickcheck", "quickcheck_macros", "approx", "oibit", "spec", "serde", "serde_test"]
test = ["quickcheck", "approx", "oibit", "spec", "serde", "serde_test"]

[dependencies]
typenum = "1.6.0"
approx = { version = "0.1.1", optional = true, features = [] }
generic-array = "0.5.1"
clippy = { version = "0.0.135", optional = true }
quickcheck = { version = "0.4.1", optional = true }
quickcheck_macros = { version = "0.4.1", optional = true }
approx = { version = "0.1.1", optional = true, features = ["no_std"] }
quickcheck = { version = "0.6.2", optional = true }
serde = { version = "1.0.0", optional = true }
serde_test = { version = "1.0.0", optional = true }
typenum = "1.6.0"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![crates.io](https://img.shields.io/crates/v/dimensioned.svg)](https://crates.io/crates/dimensioned)
[![Build Status](https://travis-ci.org/paholg/dimensioned.svg?branch=master)](https://travis-ci.org/paholg/dimensioned)

[Documentation](http://paholg.com/dimensioned/)
[Documentation](https://docs.rs/dimensioned/)

Dimensioned
=====
Expand Down
10 changes: 6 additions & 4 deletions examples/readme-example.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
extern crate dimensioned as dim;

use dim::{si, cgs};
use dim::{cgs, si};

// Calculates speed given a distance and time. Only works for SI units.
fn speed(dist: si::Meter<f64>, time: si::Second<f64>) -> si::MeterPerSecond<f64> {
dist / time
}

use std::ops::Div;
use dim::dimensions::{Length, Time};
use dim::typenum::Quot;
use std::ops::Div;

// Calculates speed as before, but now we can use *any* unit system.
fn generic_speed<L, T>(dist: L, time: T) -> Quot<L, T>
where L: Length + Div<T>, T: Time,
where
L: Length + Div<T>,
T: Time,
{
dist / time
}

fn main() {
let x = 6.0 * si::M;
let t = 3.0 * si::S;
let v = 2.0 * si::M/si::S;
let v = 2.0 * si::M / si::S;
let v2 = speed(x, t);
assert_eq!(v, v2);

Expand Down
27 changes: 12 additions & 15 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//!
//! Consider this module **unstable**.

use typenum::{Add1, B1, Length, TArr, ATerm, Len, Integer, Unsigned, U0};
use typenum::{ATerm, Add1, B1, Integer, Len, Length, TArr, U0, Unsigned};

use generic_array::{GenericArray, ArrayLength};
use generic_array::{ArrayLength, GenericArray};

use core::ops::Add;

Expand All @@ -31,37 +31,34 @@ use core::ops::Add;
/// }
/// ```
pub trait ToGA {

/// The type of the `GenericArray` to which we've converted
type Output;

/// Create a `GenericArray` of integers from a `TArr` of type numbers.
fn to_ga() -> Self::Output;
}


impl ToGA for ATerm {
type Output = GenericArray<isize, U0>;
fn to_ga() -> Self::Output {
GenericArray::new()
}
}


impl<V, A> ToGA for TArr<V, A>
where V: Integer,
A: Len + ToGA,
<A as ToGA>::Output: AppendFront<isize>,
Length<A>: Add<B1>,
Add1<Length<A>>: Unsigned + ArrayLength<isize>
where
V: Integer,
A: Len + ToGA,
<A as ToGA>::Output: AppendFront<isize>,
Length<A>: Add<B1>,
Add1<Length<A>>: Unsigned + ArrayLength<isize>,
{
type Output = <<A as ToGA>::Output as AppendFront<isize>>::Output;
fn to_ga() -> Self::Output {
A::to_ga().append_front(V::to_isize())
}
}


/// Implemented for `GenericArray`, this allows growable `GenericArray`s by appending elements to the front.
///
/// # Example
Expand All @@ -80,7 +77,6 @@ impl<V, A> ToGA for TArr<V, A>
/// }

pub trait AppendFront<T> {

/// The resulting type after performing the append
type Output;

Expand All @@ -89,9 +85,10 @@ pub trait AppendFront<T> {
}

impl<T, N> AppendFront<T> for GenericArray<T, N>
where T: Default,
N: Add<B1> + ArrayLength<T>,
Add1<N>: ArrayLength<T>
where
T: Default,
N: Add<B1> + ArrayLength<T>,
Add1<N>: ArrayLength<T>,
{
type Output = GenericArray<T, Add1<N>>;
fn append_front(self, element: T) -> Self::Output {
Expand Down
8 changes: 3 additions & 5 deletions src/build/cgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use super::*;

pub fn new() -> System {
System {
name: "CGS", module: "cgs",
name: "CGS",
module: "cgs",
doc_prelude: "The Gaussian CGS unit system
Note: this system is incomplete. More derived units and constants are coming.
Expand Down Expand Up @@ -53,10 +54,7 @@ Note: this system is incomplete. More derived units and constants are coming.
M: Centimeter = HECTO * CM.value_unsafe, "Meter";
),
fmt: false,
from: vec![
"SI",
"MKS",
],
from: vec!["SI", "MKS"],
refl_blacklist: Vec::new(),
}
}
6 changes: 3 additions & 3 deletions src/build/fps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use super::*;

pub fn new() -> System {
System {
name: "FPS", module: "fps",
name: "FPS",
module: "fps",
doc_prelude: "The foot, pound, second system, using the mass pound as a base unit.
Note: this system is incomplete. More derived units and constants are coming.
Expand All @@ -17,8 +18,7 @@ Note: this system is incomplete. More derived units and constants are coming.
FT: Foot = SqrtFoot * SqrtFoot, Length;
LB: Pound = SqrtPound * SqrtPound, Mass;
),
constants: constants!(
),
constants: constants!(),
fmt: false,
from: vec![
// "SI",
Expand Down
11 changes: 4 additions & 7 deletions src/build/mks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use super::*;

pub fn new() -> System {
System {
name: "MKS", module: "mks",
name: "MKS",
module: "mks",
doc_prelude: "The Gaussian MKS unit system
Note: this system is incomplete. More derived units and constants are coming.
Expand All @@ -19,13 +20,9 @@ Note: this system is incomplete. More derived units and constants are coming.

MPS: MeterPerSecond = Meter / Second, Velocity;
),
constants: constants!(
),
constants: constants!(),
fmt: false,
from: vec![
"SI",
"CGS",
],
from: vec!["SI", "CGS"],
refl_blacklist: Vec::new(),
}
}
Loading

0 comments on commit 3ef45da

Please # to comment.