Conversation
…al lookup to keep track of the current index
✅ Coverage Report📊 View Full HTML Report (download artifact) Overall Coverage
Changed Files in This PR
PR Files Coverage: 75.35% (743/986 lines) Generated by cargo-llvm-cov · Latest main coverage Last updated: 2026-03-04 19:10:14 UTC · Commit: |
There was a problem hiding this comment.
Pull request overview
This PR optimizes lambda-rs-args runtime argument lookup and positional assignment performance, while updating rustdoc to follow the repository’s sectioned documentation style.
Changes:
- Build a name→index map inside
ParsedArgssohas()/get_*()are O(1) instead of scanning the parsed vector. - Track a positional cursor for assigning values after
--, avoiding repeated rescans of positionals. - Expand/standardize rustdoc for
parse,compile,ParsedArgsgetters, and add a targeted test forhas()behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
crates/lambda-rs-args/src/lib.rs
Outdated
| /// Returns a count value by name, if present and typed as integer. | ||
| /// | ||
| /// # Arguments | ||
| /// - `name`: The declared argument name (for example, `"-v"`). |
There was a problem hiding this comment.
get_count's doc example uses "-v" as the lookup name, but has() (and the parse docs) explicitly state that aliases like -p are not resolved at lookup time and callers should use the declared/canonical name. Consider changing the example to a canonical long name (e.g. "--verbose") or clarifying that "-v" is only correct when it is the declared name rather than an alias.
| /// - `name`: The declared argument name (for example, `"-v"`). | |
| /// - `name`: The declared argument name (for example, `"--verbose"`). |
| /// # Errors | ||
| /// Returns `ArgsError` when: | ||
| /// - `--help` / `-h` is present (`ArgsError::HelpRequested`). | ||
| /// - An unknown argument is encountered in strict mode. | ||
| /// - A value is missing for a value-taking argument. | ||
| /// - A value fails type parsing. | ||
| /// - A required argument is not provided. | ||
| /// - Mutually exclusive or requires relationships are violated. |
There was a problem hiding this comment.
The parse rustdoc mentions "unknown argument ... in strict mode", but the API surface here is ignore_unknown(bool) and there is no named "strict mode" concept elsewhere in this crate. Consider rewording this bullet to explicitly reference ignore_unknown(false) (default) vs ignore_unknown(true) to avoid ambiguity.
| /// | ||
| /// - Aliases are resolved during parsing; lookups on `ParsedArgs` use the | ||
| /// declared argument name (canonical form), not an alias. | ||
| /// - Combined short flags like `-vvv` are supported only for `Count` and | ||
| /// `Boolean` arguments. |
There was a problem hiding this comment.
In the parse rustdoc, the last two bullets are behavior notes (alias resolution / clustered short flags), not error conditions, but they currently live under the # Errors section. Moving these into a separate section (e.g. # Notes/# Behavior) would make the docs clearer and more consistent with rustdoc section semantics.
Summary
Speed up
lambda-rs-argsparsing results and improve docs to matchlambda-rsrustdoc conventions.Related Issues
Relates to: (none)
Changes
ParsedArgssohas()/get_*()are O(1) by name instead of scanning.--is O(p) total instead of O(p^2).# Arguments/# Returns/# Errors/# Panicssections.Type of Change
Affected Crates
lambda-rslambda-rs-platformlambda-rs-argslambda-rs-loggingChecklist
cargo +nightly fmt --all)cargo clippy --workspace --all-targets -- -D warnings)cargo test --workspace)Testing
Commands run:
cargo test -p lambda-rs-argsManual verification steps (if applicable):
Screenshots/Recordings
N/A
Platform Testing
Additional Notes