#!/bin/bash
# Install Rust in WSL if not already installed

set -e

echo "Checking for Rust installation in WSL..."

# Check if rustup is already installed
if command -v rustup &> /dev/null; then
    echo "✅ Rust is already installed"
    rustup --version
    cargo --version
    exit 0
fi

echo "📦 Rust not found, installing..."

# Install Rust using rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Source cargo environment
source "$HOME/.cargo/env"

echo "✅ Rust installed successfully"
rustup --version
cargo --version
