fn from_flag(metadata: Metadata, target_flag: Option<&str>) -> Result<Self> {
        let host_target_name = rustc_version::version_meta()?.host;

        // Get the "default" target override in .cargo/config.
        let mut config_target_name = None;
        let config: toml::Value;

        if let Some(path) = search(&metadata.workspace_root, ".cargo/config") {
            config = parse(&path.join(".cargo/config"))?;
            config_target_name = config
                .get("build")
                .and_then(|build| build.get("target"))
                .and_then(|target| target.as_str());
        }

        // Find the actual target.
        let target_name = target_flag
            .or(config_target_name)
            .unwrap_or(&host_target_name);

        Self::from_target_name(target_name)
    }
/// Get a context structure from a provided target flag, used when cargo
/// was not used to build the binary.
Get a context structure from a provided target flag, used when cargo
was not used to build the binary.
Get a context structure from a provided target flag used when cargo was not used to build the binary .
fn from_flag(metadata: Metadata, target_flag: Option<&str>) -> Result<Self> {
        let host_target_name = rustc_version::version_meta()?.host;
        // Get the "default" target override in .cargo/config.
        let mut config_target_name = None;
        let config: toml::Value;
        if let Some(path) = search(&metadata.workspace_root, ".cargo/config") {
            config = parse(&path.join(".cargo/config"))?;
            config_target_name = config
                .get("build")
                .and_then(|build| build.get("target"))
                .and_then(|target| target.as_str());
        }
        // Find the actual target.
        let target_name = target_flag
            .or(config_target_name)
            .unwrap_or(&host_target_name);
        Self::from_target_name(target_name)
    }
fn from_flag ( metadata : Metadata , target_flag : Option < & str > ) -> Result < Self > { let host_target_name = rustc_version :: version_meta ( ) ? . host ; // Get the "default" target override in .cargo/config. let mut config_target_name = None ; let config : toml :: Value ; if let Some ( path ) = search ( & metadata . workspace_root , " " ) { config = parse ( & path . join ( " " ) ) ? ; config_target_name = config . get ( " " ) . and_then ( | build | build . get ( " " ) ) . and_then ( | target | target . as_str ( ) ) ; } // Find the actual target. let target_name = target_flag . or ( config_target_name ) . unwrap_or ( & host_target_name ) ; Self :: from_target_name ( target_name ) }
Get a context structure from a provided target flag, used when cargo
was not used to build the binary.
Get a context structure from a provided target flag used when cargo was not used to build the binary .
metadata
Metadata
target_flag
Option<&str>
metadata
Metadata
target_flag
Option<&str>