#!/bin/bash # Format existing exercises using rustfmt RUST_TRACK_REPO_PATH=$(cd "$(dirname "$0")/.." && pwd) EXERCISES_PATH="${RUST_TRACK_REPO_PATH}/exercises/" # Some exercises use custom formatting for illustration purpose and should not be formatted. IGNORED_EXERCISES=( "diamond" "minesweeper" "rectangles" ) # Iterate over every exercise directory and if it is not ignored - format it for exercise_dir in ${EXERCISES_PATH}/*; do exercise_name=${exercise_dir##*/} if [[ " ${IGNORED_EXERCISES[*]} " == *"$exercise_name"* ]]; then echo "$exercise_name - Ignored" else ( echo "$exercise_name - Formatting" cd "$exercise_dir" cargo fmt [ -f example.rs ] && rustfmt example.rs ) fi done