#!/usr/bin/env bash
set -euo pipefail

if [ ! -f Cargo.toml ]; then
    echo "==> No Cargo.toml found, skipping Rust checks"
    exit 0
fi

echo "==> cargo fmt --check"
cargo fmt -- --check

echo "==> cargo clippy"
cargo clippy -- -D warnings

echo "==> cargo test"
cargo test -- --test-threads=1

echo "pre-commit checks passed"
