pub fn parse_crate_data(manifest_path: &Path) -> Result<ManifestAndUnsedKeys, Error> {
        let manifest = fs::read_to_string(&manifest_path)
            .with_context(|_| format!("failed to read: {}", manifest_path.display()))?;
        let manifest = &mut toml::Deserializer::new(&manifest);

        let mut unused_keys = BTreeSet::new();
        let levenshtein_threshold = 1;

        let manifest: CargoManifest = serde_ignored::deserialize(manifest, |path| {
            let path_string = path.to_string();

            if path_string.starts_with("package.metadata")
                && (path_string.contains("wasm-pack")
                    || levenshtein(WASM_PACK_METADATA_KEY, &path_string) <= levenshtein_threshold)
            {
                unused_keys.insert(path_string);
            }
        })
        .with_context(|_| format!("failed to parse manifest: {}", manifest_path.display()))?;

        Ok(ManifestAndUnsedKeys {
            manifest,
            unused_keys,
        })
    }
/// Read the `manifest_path` file and deserializes it using the toml Deserializer.
/// Returns a Result containing `ManifestAndUnsedKeys` which contains `CargoManifest`
/// and a `BTreeSet<String>` containing the unused keys from the parsed file.
///
/// # Errors
/// Will return Err if the file (manifest_path) couldn't be read or
/// if deserialize to `CargoManifest` fails.
Read the `manifest_path` file and deserializes it using the toml Deserializer.
Read the ` manifest_path ` file and deserializes it using the toml Deserializer .
pub fn parse_crate_data(manifest_path: &Path) -> Result<ManifestAndUnsedKeys, Error> {
        let manifest = fs::read_to_string(&manifest_path)
            .with_context(|_| format!("failed to read: {}", manifest_path.display()))?;
        let manifest = &mut toml::Deserializer::new(&manifest);
        let mut unused_keys = BTreeSet::new();
        let levenshtein_threshold = 1;
        let manifest: CargoManifest = serde_ignored::deserialize(manifest, |path| {
            let path_string = path.to_string();
            if path_string.starts_with("package.metadata")
                && (path_string.contains("wasm-pack")
                    || levenshtein(WASM_PACK_METADATA_KEY, &path_string) <= levenshtein_threshold)
            {
                unused_keys.insert(path_string);
            }
        })
        .with_context(|_| format!("failed to parse manifest: {}", manifest_path.display()))?;
        Ok(ManifestAndUnsedKeys {
            manifest,
            unused_keys,
        })
    }
pub fn parse_crate_data ( manifest_path : & Path ) -> Result < ManifestAndUnsedKeys , Error > { let manifest = fs :: read_to_string ( & manifest_path ) . with_context ( | _ | format ! ( " " manifest_path display ( ) ) ) ? ; let manifest = & mut toml :: Deserializer :: new ( & manifest ) ; let mut unused_keys = BTreeSet :: new ( ) ; let levenshtein_threshold = 1 ; let manifest : CargoManifest = serde_ignored :: deserialize ( manifest , | path | { let path_string = path . to_string ( ) ; if path_string . starts_with ( " " ) && ( path_string . contains ( " " ) || levenshtein ( WASM_PACK_METADATA_KEY , & path_string ) <= levenshtein_threshold ) { unused_keys . insert ( path_string ) ; } } ) . with_context ( | _ | format ! ( " " manifest_path display ( ) ) ) ? ; Ok ( ManifestAndUnsedKeys { manifest , unused_keys , } ) }
Read the `manifest_path` file and deserializes it using the toml Deserializer.
Read the ` manifest_path ` file and deserializes it using the toml Deserializer .
manifest_path
&Path
errors
Will return Err if the file (manifest_path) couldn't be read or
if deserialize to `CargoManifest` fails.
Will return Err if the file ( manifest_path ) couldn ' t be read or if deserialize to ` CargoManifest ` fails .