Skip to main content

infer_group

Function infer_group 

Source
pub fn infer_group(manifest_text: &str) -> GroupKind
Expand description

Infer the contextual group type from a Cargo.toml’s text: a manifest that declares a [workspace] table is a GroupKind::CargoWorkspace, otherwise a GroupKind::CargoCrate. This probes only the provided manifest — the authoritative member and target data still comes from cargo metadata.

§Examples

use coding_tools::survey::{infer_group, GroupKind};

assert_eq!(infer_group("[workspace]\nmembers = [\"a\"]\n"), GroupKind::CargoWorkspace);
assert_eq!(infer_group("[workspace.package]\nversion = \"1\"\n"), GroupKind::CargoWorkspace);
assert_eq!(infer_group("[package]\nname = \"x\"\n"), GroupKind::CargoCrate);
// A commented-out header does not count.
assert_eq!(infer_group("# [workspace]\n[package]\n"), GroupKind::CargoCrate);