cargo-fixit 0.1.7

Proposed fixit commands for cargo
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::{path::PathBuf, process::Command, sync::OnceLock};

static SYSROOT: OnceLock<Option<PathBuf>> = OnceLock::new();

pub(crate) fn get_sysroot() -> &'static Option<PathBuf> {
    SYSROOT.get_or_init(|| {
        Command::new("rustc")
            .arg("--print=sysroot")
            .output()
            .map(|x| String::from_utf8_lossy(&x.stdout).trim().to_owned())
            .map(PathBuf::from)
            .ok()
    })
}