fn toml(root: &Root) -> Result<Option<CrossToml>> {
    let cross_config_path = match env::var("CROSS_CONFIG") {
        Ok(var) => PathBuf::from(var),
        Err(_) => root.path().join("Cross.toml"),
    };

    // Attempts to read the cross config from the Cargo.toml
    let cargo_toml_str =
        file::read(root.path().join("Cargo.toml")).wrap_err("failed to read Cargo.toml")?;
    let cargo_cross_toml_opt = CrossToml::parse_from_cargo(&cargo_toml_str)?;

    match (
        cross_config_path.exists(),
        cargo_cross_toml_opt.map(|(cfg, _)| cfg),
    ) {
        (true, Some(_)) => {
            eprintln!("Found a cross configuration (e.g. Cross.toml) and a configuration in your Cargo.toml. Please use only one of these options.");
            Ok(None)
        }
        (true, None) => {
            let content = file::read(&cross_config_path).wrap_err_with(|| {
                format!("could not read file `{}`", cross_config_path.display())
            })?;

            let (config, _) = CrossToml::parse(&content).wrap_err_with(|| {
                format!(
                    "failed to parse file `{}` as TOML",
                    cross_config_path.display()
                )
            })?;

            Ok(Some(config))
        }
        (false, Some(cfg)) => Ok(Some(cfg)),
        (false, None) => {
            // Checks if there is a lowercase version of this file
            if root.path().join("cross.toml").exists() {
                eprintln!("There's a file named cross.toml, instead of Cross.toml. You may want to rename it, or it won't be considered.");
            }

            Ok(None)
        }
    }
}
/// Obtains the [`CrossToml`] from one of the possible locations
///
/// These locations are checked in the following order:
/// 1. Package metadata in the Cargo.toml
/// 2. If the `CROSS_CONFIG` variable is set, it tries to read the config from its value
/// 3. Otherwise, the `Cross.toml` in the project root is set.
Obtains the [`CrossToml`] from one of the possible locations
These locations are checked in the following order:
1. Package metadata in the Cargo.toml
2. If the `CROSS_CONFIG` variable is set, it tries to read the config from its value
3. Otherwise, the `Cross.toml` in the project root is set.
Obtains the [ ` CrossToml ` ] from one of the possible locations These locations are checked in the following order : 1 . Package metadata in the Cargo . toml 2 . If the ` CROSS_CONFIG ` variable is set it tries to read the config from its value 3 . Otherwise the ` Cross . toml ` in the project root is set .
fn toml(root: &Root) -> Result<Option<CrossToml>> {
    let cross_config_path = match env::var("CROSS_CONFIG") {
        Ok(var) => PathBuf::from(var),
        Err(_) => root.path().join("Cross.toml"),
    };
    // Attempts to read the cross config from the Cargo.toml
    let cargo_toml_str =
        file::read(root.path().join("Cargo.toml")).wrap_err("failed to read Cargo.toml")?;
    let cargo_cross_toml_opt = CrossToml::parse_from_cargo(&cargo_toml_str)?;
    match (
        cross_config_path.exists(),
        cargo_cross_toml_opt.map(|(cfg, _)| cfg),
    ) {
        (true, Some(_)) => {
            eprintln!("Found a cross configuration (e.g. Cross.toml) and a configuration in your Cargo.toml. Please use only one of these options.");
            Ok(None)
        }
        (true, None) => {
            let content = file::read(&cross_config_path).wrap_err_with(|| {
                format!("could not read file `{}`", cross_config_path.display())
            })?;
            let (config, _) = CrossToml::parse(&content).wrap_err_with(|| {
                format!(
                    "failed to parse file `{}` as TOML",
                    cross_config_path.display()
                )
            })?;
            Ok(Some(config))
        }
        (false, Some(cfg)) => Ok(Some(cfg)),
        (false, None) => {
            // Checks if there is a lowercase version of this file
            if root.path().join("cross.toml").exists() {
                eprintln!("There's a file named cross.toml, instead of Cross.toml. You may want to rename it, or it won't be considered.");
            }
            Ok(None)
        }
    }
}
fn toml ( root : & Root ) -> Result < Option < CrossToml > > { let cross_config_path = match env :: var ( " " ) { Ok ( var ) => PathBuf :: from ( var ) , Err ( _ ) => root . path ( ) . join ( " " ) , } ; // Attempts to read the cross config from the Cargo.toml let cargo_toml_str = file :: read ( root . path ( ) . join ( " " ) ) . wrap_err ( " " ) ? ; let cargo_cross_toml_opt = CrossToml :: parse_from_cargo ( & cargo_toml_str ) ? ; match ( cross_config_path . exists ( ) , cargo_cross_toml_opt . map ( | ( cfg , _ ) | cfg ) , ) { ( true , Some ( _ ) ) => { eprintln ! ( " " ) ; Ok ( None ) } ( true , None ) => { let content = file :: read ( & cross_config_path ) . wrap_err_with ( | | { format ! ( " " cross_config_path display ( ) ) } ) ? ; let ( config , _ ) = CrossToml :: parse ( & content ) . wrap_err_with ( | | { format ! ( " " cross_config_path display ( ) ) } ) ? ; Ok ( Some ( config ) ) } ( false , Some ( cfg ) ) => Ok ( Some ( cfg ) ) , ( false , None ) => { // Checks if there is a lowercase version of this file if root . path ( ) . join ( " " ) . exists ( ) { eprintln ! ( " " ) ; } Ok ( None ) } } }
Obtains the [`CrossToml`] from one of the possible locations
These locations are checked in the following order:
1.
Obtains the [ ` CrossToml ` ] from one of the possible locations These locations are checked in the following order : 1 .
root
&Root
root
&Root