pub fn bundle<P: AsRef<Path>>(package_path: P) -> String {
    let manifest_path = package_path.as_ref().join("Cargo.toml");
    let metadata = cargo_metadata::metadata_deps(Some(&manifest_path), false)
        .expect("failed to obtain cargo metadata");
    let targets = &metadata.packages[0].targets;
    let bins: Vec<_> = targets.iter().filter(|t| target_is(t, "bin")).collect();
    assert!(bins.len() != 0, "no binary target found");
    assert!(bins.len() == 1, "multiple binary targets not supported");
    let bin = bins[0];
    let libs: Vec<_> = targets.iter().filter(|t| target_is(t, "lib")).collect();
    assert!(libs.len() <= 1, "multiple library targets not supported");
    let lib = libs.get(0).unwrap_or(&bin);
    let base_path = Path::new(&lib.src_path)
        .parent()
        .expect("lib.src_path has no parent");
    let crate_name = &lib.name;
    eprintln!("expanding binary {}", bin.src_path);
    let code = read_file(&Path::new(&bin.src_path)).expect("failed to read binary target source");
    let mut file = syn::parse_file(&code).expect("failed to parse binary target source");
    Expander {
        base_path,
        crate_name,
    }.visit_file_mut(&mut file);
    let code = file.into_tokens().to_string();
    prettify(code)
}
/// Creates a single-source-file version of a Cargo package.
Creates a single-source-file version of a Cargo package.
Creates a single - source - file version of a Cargo package .
pub fn bundle<P: AsRef<Path>>(package_path: P) -> String {
    let manifest_path = package_path.as_ref().join("Cargo.toml");
    let metadata = cargo_metadata::metadata_deps(Some(&manifest_path), false)
        .expect("failed to obtain cargo metadata");
    let targets = &metadata.packages[0].targets;
    let bins: Vec<_> = targets.iter().filter(|t| target_is(t, "bin")).collect();
    assert!(bins.len() != 0, "no binary target found");
    assert!(bins.len() == 1, "multiple binary targets not supported");
    let bin = bins[0];
    let libs: Vec<_> = targets.iter().filter(|t| target_is(t, "lib")).collect();
    assert!(libs.len() <= 1, "multiple library targets not supported");
    let lib = libs.get(0).unwrap_or(&bin);
    let base_path = Path::new(&lib.src_path)
        .parent()
        .expect("lib.src_path has no parent");
    let crate_name = &lib.name;
    eprintln!("expanding binary {}", bin.src_path);
    let code = read_file(&Path::new(&bin.src_path)).expect("failed to read binary target source");
    let mut file = syn::parse_file(&code).expect("failed to parse binary target source");
    Expander {
        base_path,
        crate_name,
    }.visit_file_mut(&mut file);
    let code = file.into_tokens().to_string();
    prettify(code)
}
pub fn bundle < P : AsRef < Path > > ( package_path : P ) -> String { let manifest_path = package_path . as_ref ( ) . join ( " " ) ; let metadata = cargo_metadata :: metadata_deps ( Some ( & manifest_path ) , false ) . expect ( " " ) ; let targets = & metadata . packages [ 0 ] . targets ; let bins : Vec < _ > = targets . iter ( ) . filter ( | t | target_is ( t , " " ) ) . collect ( ) ; assert ! ( bins len ( ) 0 " " ) ; assert ! ( bins len ( ) 1 " " ) ; let bin = bins [ 0 ] ; let libs : Vec < _ > = targets . iter ( ) . filter ( | t | target_is ( t , " " ) ) . collect ( ) ; assert ! ( libs len ( ) 1 " " ) ; let lib = libs . get ( 0 ) . unwrap_or ( & bin ) ; let base_path = Path :: new ( & lib . src_path ) . parent ( ) . expect ( " " ) ; let crate_name = & lib . name ; eprintln ! ( " " bin src_path ) ; let code = read_file ( & Path :: new ( & bin . src_path ) ) . expect ( " " ) ; let mut file = syn :: parse_file ( & code ) . expect ( " " ) ; Expander { base_path , crate_name , } . visit_file_mut ( & mut file ) ; let code = file . into_tokens ( ) . to_string ( ) ; prettify ( code ) }
Creates a single-source-file version of a Cargo package.
Creates a single - source - file version of a Cargo package .
package_path
P
package_path
P