steps:
  - bash: |
      set -e
      toolchain=$TOOLCHAIN
      if [ "$toolchain" = "" ]; then
        toolchain=stable
      fi
      if command -v rustup; then
        rustup update $toolchain
        rustup default $toolchain
      else
        curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $toolchain
        echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
      fi
    displayName: Install rust (unix)
    condition: ne( variables['Agent.OS'], 'Windows_NT' )

  - bash: rustup update stable-$TOOLCHAIN && rustup default stable-$TOOLCHAIN
    displayName: Install rust (windows)
    condition: eq( variables['Agent.OS'], 'Windows_NT' )

  - script: |
        rustc -Vv
        cargo -V
    displayName: Query rust and cargo versions
