pub fn new(base: &AbsPath, data: ProjectJsonData) -> ProjectJson {
        ProjectJson {
            sysroot_src: data.sysroot_src.map(|it| base.join(it)),
            project_root: base.to_path_buf(),
            crates: data
                .crates
                .into_iter()
                .map(|crate_data| {
                    let is_workspace_member = crate_data.is_workspace_member.unwrap_or_else(|| {
                        crate_data.root_module.is_relative()
                            && !crate_data.root_module.starts_with("..")
                            || crate_data.root_module.starts_with(base)
                    });
                    let root_module = base.join(crate_data.root_module).normalize();
                    let (include, exclude) = match crate_data.source {
                        Some(src) => {
                            let absolutize = |dirs: Vec<PathBuf>| {
                                dirs.into_iter()
                                    .map(|it| base.join(it).normalize())
                                    .collect::<Vec<_>>()
                            };
                            (absolutize(src.include_dirs), absolutize(src.exclude_dirs))
                        }
                        None => (vec![root_module.parent().unwrap().to_path_buf()], Vec::new()),
                    };

                    Crate {
                        root_module,
                        edition: crate_data.edition.into(),
                        deps: crate_data
                            .deps
                            .into_iter()
                            .map(|dep_data| Dependency {
                                crate_id: CrateId(dep_data.krate as u32),
                                name: dep_data.name,
                            })
                            .collect::<Vec<_>>(),
                        cfg: crate_data.cfg,
                        target: crate_data.target,
                        env: crate_data.env,
                        proc_macro_dylib_path: crate_data
                            .proc_macro_dylib_path
                            .map(|it| base.join(it)),
                        is_workspace_member,
                        include,
                        exclude,
                    }
                })
                .collect::<Vec<_>>(),
        }
    }
/// Create a new ProjectJson instance.
///
/// # Arguments
///
/// * `base` - The path to the workspace root (i.e. the folder containing `rust-project.json`)
/// * `data` - The parsed contents of `rust-project.json`, or project json that's passed via
///            configuration.
Create a new ProjectJson instance.
Create a new ProjectJson instance .
pub fn new(base: &AbsPath, data: ProjectJsonData) -> ProjectJson {
        ProjectJson {
            sysroot_src: data.sysroot_src.map(|it| base.join(it)),
            project_root: base.to_path_buf(),
            crates: data
                .crates
                .into_iter()
                .map(|crate_data| {
                    let is_workspace_member = crate_data.is_workspace_member.unwrap_or_else(|| {
                        crate_data.root_module.is_relative()
                            && !crate_data.root_module.starts_with("..")
                            || crate_data.root_module.starts_with(base)
                    });
                    let root_module = base.join(crate_data.root_module).normalize();
                    let (include, exclude) = match crate_data.source {
                        Some(src) => {
                            let absolutize = |dirs: Vec<PathBuf>| {
                                dirs.into_iter()
                                    .map(|it| base.join(it).normalize())
                                    .collect::<Vec<_>>()
                            };
                            (absolutize(src.include_dirs), absolutize(src.exclude_dirs))
                        }
                        None => (vec![root_module.parent().unwrap().to_path_buf()], Vec::new()),
                    };
                    Crate {
                        root_module,
                        edition: crate_data.edition.into(),
                        deps: crate_data
                            .deps
                            .into_iter()
                            .map(|dep_data| Dependency {
                                crate_id: CrateId(dep_data.krate as u32),
                                name: dep_data.name,
                            })
                            .collect::<Vec<_>>(),
                        cfg: crate_data.cfg,
                        target: crate_data.target,
                        env: crate_data.env,
                        proc_macro_dylib_path: crate_data
                            .proc_macro_dylib_path
                            .map(|it| base.join(it)),
                        is_workspace_member,
                        include,
                        exclude,
                    }
                })
                .collect::<Vec<_>>(),
        }
    }
pub fn new ( base : & AbsPath , data : ProjectJsonData ) -> ProjectJson { ProjectJson { sysroot_src : data . sysroot_src . map ( | it | base . join ( it ) ) , project_root : base . to_path_buf ( ) , crates : data . crates . into_iter ( ) . map ( | crate_data | { let is_workspace_member = crate_data . is_workspace_member . unwrap_or_else ( | | { crate_data . root_module . is_relative ( ) && ! crate_data . root_module . starts_with ( " " ) || crate_data . root_module . starts_with ( base ) } ) ; let root_module = base . join ( crate_data . root_module ) . normalize ( ) ; let ( include , exclude ) = match crate_data . source { Some ( src ) => { let absolutize = | dirs : Vec < PathBuf > | { dirs . into_iter ( ) . map ( | it | base . join ( it ) . normalize ( ) ) . collect :: < Vec < _ > > ( ) } ; ( absolutize ( src . include_dirs ) , absolutize ( src . exclude_dirs ) ) } None => ( vec ! [ root_module parent ( ) unwrap ( ) to_path_buf ( ) ] , Vec :: new ( ) ) , } ; Crate { root_module , edition : crate_data . edition . into ( ) , deps : crate_data . deps . into_iter ( ) . map ( | dep_data | Dependency { crate_id : CrateId ( dep_data . krate as u32 ) , name : dep_data . name , } ) . collect :: < Vec < _ > > ( ) , cfg : crate_data . cfg , target : crate_data . target , env : crate_data . env , proc_macro_dylib_path : crate_data . proc_macro_dylib_path . map ( | it | base . join ( it ) ) , is_workspace_member , include , exclude , } } ) . collect :: < Vec < _ > > ( ) , } }
Create a new ProjectJson instance.
Create a new ProjectJson instance .
base
&AbsPath
data
ProjectJsonData