fn find_wasm_bindgen_version<'a>(cfg: &'a ConfigOptsTools, manifest: &CargoMetadata) -> Option<Cow<'a, str>> {
    let find_lock = || -> Option<Cow<'_, str>> {
        let lock_path = Path::new(&manifest.manifest_path).parent()?.join("Cargo.lock");
        let lockfile = Lockfile::load(lock_path).ok()?;
        let name = "wasm-bindgen".parse().ok()?;

        lockfile
            .packages
            .into_iter()
            .find(|p| p.name == name)
            .map(|p| Cow::from(p.version.to_string()))
    };

    let find_manifest = || -> Option<Cow<'_, str>> {
        manifest
            .metadata
            .packages
            .iter()
            .find(|p| p.name == "wasm-bindgen")
            .map(|p| Cow::from(p.version.to_string()))
    };

    cfg.wasm_bindgen
        .as_deref()
        .map(Cow::from)
        .or_else(find_lock)
        .or_else(find_manifest)
}
/// Find the appropriate versio of `wasm-bindgen` to use. The version can be found in 3 different
/// location in order:
/// - Defined in the `Trunk.toml` as highest priority.
/// - Located in the `Cargo.lock` if it exists. This is mostly the case as we run `cargo build`
///   before even calling this function.
/// - Located in the `Cargo.toml` as direct dependency of the project.
Find the appropriate versio of `wasm-bindgen` to use. The version can be found in 3 different
location in order:
Defined in the `Trunk.toml` as highest priority.
Located in the `Cargo.lock` if it exists. This is mostly the case as we run `cargo build`
before even calling this function.
Located in the `Cargo.toml` as direct dependency of the project.
Find the appropriate versio of ` wasm - bindgen ` to use . The version can be found in 3 different location in order : Defined in the ` Trunk . toml ` as highest priority . Located in the ` Cargo . lock ` if it exists . This is mostly the case as we run ` cargo build ` before even calling this function . Located in the ` Cargo . toml ` as direct dependency of the project .
fn find_wasm_bindgen_version<'a>(cfg: &'a ConfigOptsTools, manifest: &CargoMetadata) -> Option<Cow<'a, str>> {
    let find_lock = || -> Option<Cow<'_, str>> {
        let lock_path = Path::new(&manifest.manifest_path).parent()?.join("Cargo.lock");
        let lockfile = Lockfile::load(lock_path).ok()?;
        let name = "wasm-bindgen".parse().ok()?;
        lockfile
            .packages
            .into_iter()
            .find(|p| p.name == name)
            .map(|p| Cow::from(p.version.to_string()))
    };
    let find_manifest = || -> Option<Cow<'_, str>> {
        manifest
            .metadata
            .packages
            .iter()
            .find(|p| p.name == "wasm-bindgen")
            .map(|p| Cow::from(p.version.to_string()))
    };
    cfg.wasm_bindgen
        .as_deref()
        .map(Cow::from)
        .or_else(find_lock)
        .or_else(find_manifest)
}
fn find_wasm_bindgen_version < ' a > ( cfg : & ' a ConfigOptsTools , manifest : & CargoMetadata ) -> Option < Cow < ' a , str > > { let find_lock = | | -> Option < Cow < ' _ , str > > { let lock_path = Path :: new ( & manifest . manifest_path ) . parent ( ) ? . join ( " " ) ; let lockfile = Lockfile :: load ( lock_path ) . ok ( ) ? ; let name = " " . parse ( ) . ok ( ) ? ; lockfile . packages . into_iter ( ) . find ( | p | p . name == name ) . map ( | p | Cow :: from ( p . version . to_string ( ) ) ) } ; let find_manifest = | | -> Option < Cow < ' _ , str > > { manifest . metadata . packages . iter ( ) . find ( | p | p . name == " " ) . map ( | p | Cow :: from ( p . version . to_string ( ) ) ) } ; cfg . wasm_bindgen . as_deref ( ) . map ( Cow :: from ) . or_else ( find_lock ) . or_else ( find_manifest ) }
Find the appropriate versio of `wasm-bindgen` to use.
Find the appropriate versio of ` wasm - bindgen ` to use .
cfg
&'a ConfigOptsTools
manifest
&CargoMetadata
cfg
&'a ConfigOptsTools
manifest
&CargoMetadata