fn from_artifact(metadata: Metadata, artifact: &Artifact) -> Result<Self> {
        // Currently there is no clean way to get the target triple from cargo so we can only make
        // an approximation, we do this by extracting the target triple from the artifacts path.
        // For more info on the path structure see: https://doc.rust-lang.org/cargo/guide/build-cache.html

        // In the future it may be possible to replace this code and use a cargo feature:
        // See: https://github.com/rust-lang/cargo/issues/5579, https://github.com/rust-lang/cargo/issues/8002

        // Should always succeed.
        let target_path = artifact.filenames[0].strip_prefix(metadata.target_directory)?;
        let target_name = if let Some(Component::Normal(path)) = target_path.components().next() {
            let path = path.to_string_lossy();
            // TODO: How will custom profiles impact this?
            if path == "debug" || path == "release" {
                // Looks like this artifact was built for the host.
                rustc_version::version_meta()?.host
            } else {
                // The artifact
                path.to_string()
            }
        } else {
            unreachable!();
        };

        Self::from_target_name(&target_name)
    }
/// Get a context structure from a built artifact.
Get a context structure from a built artifact.
Get a context structure from a built artifact .
fn from_artifact(metadata: Metadata, artifact: &Artifact) -> Result<Self> {
        // Currently there is no clean way to get the target triple from cargo so we can only make
        // an approximation, we do this by extracting the target triple from the artifacts path.
        // For more info on the path structure see: https://doc.rust-lang.org/cargo/guide/build-cache.html
        // In the future it may be possible to replace this code and use a cargo feature:
        // See: https://github.com/rust-lang/cargo/issues/5579, https://github.com/rust-lang/cargo/issues/8002
        // Should always succeed.
        let target_path = artifact.filenames[0].strip_prefix(metadata.target_directory)?;
        let target_name = if let Some(Component::Normal(path)) = target_path.components().next() {
            let path = path.to_string_lossy();
            // TODO: How will custom profiles impact this?
            if path == "debug" || path == "release" {
                // Looks like this artifact was built for the host.
                rustc_version::version_meta()?.host
            } else {
                // The artifact
                path.to_string()
            }
        } else {
            unreachable!();
        };
        Self::from_target_name(&target_name)
    }
fn from_artifact ( metadata : Metadata , artifact : & Artifact ) -> Result < Self > { // Currently there is no clean way to get the target triple from cargo so we can only make // an approximation, we do this by extracting the target triple from the artifacts path. // For more info on the path structure see: https://doc.rust-lang.org/cargo/guide/build-cache.html // In the future it may be possible to replace this code and use a cargo feature: // See: https://github.com/rust-lang/cargo/issues/5579, https://github.com/rust-lang/cargo/issues/8002 // Should always succeed. let target_path = artifact . filenames [ 0 ] . strip_prefix ( metadata . target_directory ) ? ; let target_name = if let Some ( Component :: Normal ( path ) ) = target_path . components ( ) . next ( ) { let path = path . to_string_lossy ( ) ; // TODO: How will custom profiles impact this? if path == " " || path == " " { // Looks like this artifact was built for the host. rustc_version :: version_meta ( ) ? . host } else { // The artifact path . to_string ( ) } } else { unreachable ! ( ) ; } ; Self :: from_target_name ( & target_name ) }
Get a context structure from a built artifact.
Get a context structure from a built artifact .
metadata
Metadata
artifact
&Artifact
metadata
Metadata
artifact
&Artifact