Repository: starship/starship
File: src/modules/rust.rs (Rust)

Code before:
    {
        match execute_rustup_run_rustc_version(&toolchain) {
            RustupRunRustcVersionOutcome::RustcVersion(rustc_version) => {
                format_rustc_version(&rustc_version, config.version_format)
            }
            RustupRunRustcVersionOutcome::ToolchainName(toolchain) => Some(toolchain),
            RustupRunRustcVersionOutcome::RustupNotWorking => {
                // If `rustup` is not in `$PATH` or cannot be executed for other reasons, we can
                // safely execute `rustc --version`.
                format_rustc_version(&execute_rustc_version()?, config.version_format)
            }
            RustupRunRustcVersionOutcome::Err => None,
        }
    } else {
        format_rustc_version(&execute_rustc_version()?, config.version_format)
    }
}

fn env_rustup_toolchain(context: &Context) -> Option<String> {
    let val = context.get_env("RUSTUP_TOOLCHAIN")?;
    Some(val.trim().to_owned())
}

fn execute_rustup_override_list(context: &Context) -> Option<String> {
    extract_toolchain_from_rustup_override_list(
        &context.exec_cmd("rustup", &["default"])?.stdout,
        &context.current_dir,
    )
}

fn execute_rustup_default(context: &Context) -> Option<String> {
    // `rustup default` output is:
    //    stable-x86_64-apple-darwin (default)
    context
        .exec_cmd("rustup", &["default"])?
        .stdout
        .split_whitespace()
        .next()
        .map(str::to_owned)
}

fn extract_toolchain_from_rustup_override_list(stdout: &str, cwd: &Path) -> Option<String> {
    if stdout == "no overrides\n" {
        return None;
    }
    stdout
        .lines()
        .filter_map(|line| {
            let mut words = line.split_whitespace();
            let dir = words.next()?;
            let toolchain = words.next()?;

Review comment (suggestion):
Should this not be

```suggestion
        &context.exec_cmd("rustup", &["override", "list"])?.stdout,
```


Code after:
    {
        match execute_rustup_run_rustc_version(&toolchain) {
            RustupRunRustcVersionOutcome::RustcVersion(rustc_version) => {
                format_rustc_version(&rustc_version, config.version_format)
            }
            RustupRunRustcVersionOutcome::ToolchainName(toolchain) => Some(toolchain),
            RustupRunRustcVersionOutcome::RustupNotWorking => {
                // If `rustup` is not in `$PATH` or cannot be executed for other reasons, we can
                // safely execute `rustc --version`.
                format_rustc_version(&execute_rustc_version()?, config.version_format)
            }
            RustupRunRustcVersionOutcome::Err => None,
        }
    } else {
        format_rustc_version(&execute_rustc_version()?, config.version_format)
    }
}

fn env_rustup_toolchain(context: &Context) -> Option<String> {
    let val = context.get_env("RUSTUP_TOOLCHAIN")?;
    Some(val.trim().to_owned())
}

fn execute_rustup_override_list(context: &Context) -> Option<String> {
    extract_toolchain_from_rustup_override_list(
        &context.exec_cmd("rustup", &["override", "list"])?.stdout,
        &context.current_dir,
    )
}

fn execute_rustup_default(context: &Context) -> Option<String> {
    // `rustup default` output is:
    //    stable-x86_64-apple-darwin (default)
    context
        .exec_cmd("rustup", &["default"])?
        .stdout
        .split_whitespace()
        .next()
        .map(str::to_owned)
}

fn extract_toolchain_from_rustup_override_list(stdout: &str, cwd: &Path) -> Option<String> {
    if stdout == "no overrides\n" {
        return None;
    }
    stdout
        .lines()
        .filter_map(|line| {
            let mut words = line.split_whitespace();
            let dir = words.next()?;
            let toolchain = words.next()?;