diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3e850bc..5956f11 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -170,3 +170,18 @@ jobs: run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock - name: "Run test script" run: ./maintainer-tools/ci/run_task.sh docsrs + + Format: # 1 job, run cargo fmt directly. + name: Format - nightly toolchain + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@nightly + - name: "Install rustfmt" + run: rustup component add rustfmt + - name: "Check formatting" + run: cargo +nightly fmt --all -- --check diff --git a/examples/point.rs b/examples/point.rs index f8875df..b4bdb95 100644 --- a/examples/point.rs +++ b/examples/point.rs @@ -17,7 +17,9 @@ fn main() { println!(); println!("Looking in map for key: {}", a); - let found = map.get(Ordered::from_ref(&a)).expect("failed to look up key"); + let found = map + .get(Ordered::from_ref(&a)) + .expect("failed to look up key"); println!("Found it, with value: {}", found); } diff --git a/src/lib.rs b/src/lib.rs index 1da6142..2717e63 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -87,15 +87,11 @@ impl Ordered { /// Creates an `Ordered` from a reference. /// /// This allows: `let found = map.get(Ordered::from_ref(&a));` - pub fn from_ref(value: &T) -> &Self { - unsafe { &*(value as *const _ as *const Self) } - } + pub fn from_ref(value: &T) -> &Self { unsafe { &*(value as *const _ as *const Self) } } } impl ArbitraryOrd for &T { - fn arbitrary_cmp(&self, other: &Self) -> Ordering { - (*self).arbitrary_cmp(other) - } + fn arbitrary_cmp(&self, other: &Self) -> Ordering { (*self).arbitrary_cmp(other) } } impl PartialOrd for Ordered { @@ -155,7 +151,9 @@ mod tests { } impl ArbitraryOrd for Point { - fn arbitrary_cmp(&self, other: &Self) -> Ordering { (self.x, self.y).cmp(&(other.x, other.y)) } + fn arbitrary_cmp(&self, other: &Self) -> Ordering { + (self.x, self.y).cmp(&(other.x, other.y)) + } } #[test]