Skip to main content

Module crate_root

Module crate_root 

Source
Expand description

Where the module walk starts: the library target’s root file.

Cargo takes it from [lib] path in Cargo.toml. Without that key the lint keeps its two guesses: src/lib.rs when the crate has a src/ directory, else lib.rs next to Cargo.toml (every scaffolded R package sets [lib] path = "lib.rs", so the guess only matters for manifests without it).

The key is read with a small line-based scanner, so the lint gains no TOML dependency. Mirror of the reader in miniextendr-macros/src/crate_config.rs (normalize_key, parse_string_value): the current table header is tracked and every key = value line resolves to a dotted path, so [lib] followed by path = "..." and a top-level lib.path = "..." are the same key, and a path under any other table ([[bin]], [package], [dependencies.lib]) is a different one.

Structs§

CrateRoot
The library target’s root file, resolved for a manifest directory.

Enums§

RootOrigin
Where CrateRoot::file came from.

Constants§

LIB_PATH_KEY 🔒
Dotted path of the key that names the library target’s root file.

Functions§

inline_table_has_path 🔒
Whether a one-line inline table names a path key. Splitting on , can cut an array or a string apart, but every key still starts a piece of its own.
lib_path_from_manifest 🔒
The [lib] path value of manifest text, None when the key is absent.
normalize 🔒
manifest_dir.join(path) without . components, so path = "./lib.rs" names the same file as path = "lib.rs".
normalize_key 🔒
Collapse a dotted key or table header to a.b.c: trims each segment and strips one layer of quotes so [ "lib" ] compares equal to [lib].
parse_string_value 🔒
Parse a single-line TOML basic ("...") or literal ('...') string, allowing a trailing # comment. Escape sequences in a basic string, multi-line strings and non-string values return None. Unlike the macro crate’s copy, a literal string keeps its backslashes (TOML has no escapes there), so path = 'rust\lib.rs' reads as written.
prose_links_keep 🔒
Whether the crate sets roxygen_prose_links = "keep" under [package.metadata.miniextendr]: leading doc prose then keeps its links on the way to roxygen2. Same line scanner as lib_path_from_manifest; a missing, unreadable or malformed value reads as the default ("strip").