Skip to content

Instantly share code, notes, and snippets.

@HenkPoley
Created July 7, 2025 18:43
Show Gist options
  • Save HenkPoley/6bc7f6108706b01d01806e9f14a4885c to your computer and use it in GitHub Desktop.
Save HenkPoley/6bc7f6108706b01d01806e9f14a4885c to your computer and use it in GitHub Desktop.

Revisions

  1. HenkPoley created this gist Jul 7, 2025.
    33 changes: 33 additions & 0 deletions rust_env.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    #!/usr/bin/env bash

    set -euo pipefail

    CARGO_TOML="Cargo.toml"

    PROFILE_CHUNK=$(cat <<'EOF'
    [profile.dev]
    opt-level = 0
    debug = 0
    incremental = true
    codegen-units = 256
    panic = "unwind"
    lto = false
    overflow-checks = false
    [profile.test]
    inherits = "dev"
    EOF
    )

    # Check if profile.dev already exists
    if grep -q "^\[profile\.dev\]" "$CARGO_TOML"; then
    echo "Cargo.toml already contains [profile.dev], skipping patch."
    else
    echo "Appending dev/test profiles to $CARGO_TOML"
    echo "$PROFILE_CHUNK" >> "$CARGO_TOML"
    fi

    rustup update
    cargo fetch
    cargo install --path . --profile dev