#!/usr/bin/env bash
# Installed by `just dev-setup`. Skip once with `git commit --no-verify`.
set -euo pipefail

git diff --cached --name-only --diff-filter=ACM -- '*.rs' | grep -q . || exit 0

if ! cargo fmt --check >/dev/null; then
  echo "rustfmt needed; run \`just fmt\`, then stage the result" >&2
  exit 1
fi
cargo clippy --quiet --all-targets -- -D warnings
