find_package

Function find_package 

Source
pub fn find_package(manifest_path: Option<&Path>) -> Result<Package>
Expand description

Find the Cargo package using cargo_metadata.

This automatically respects Cargo’s --manifest-path option when running as a cargo subcommand.

Returns the package that corresponds to the current context, in order:

  1. Package whose directory matches the current working directory
  2. Package whose manifest path matches current_dir/Cargo.toml
  3. Root package (if workspace has a root package)
  4. First default-member (if workspace has default-members configured)
  5. Error if no package can be determined