Skip to content

Use longer lifetime in clap_lex ParsedArg#6221

Merged
epage merged 1 commit intoclap-rs:masterfrom
sffc:lex-lifetime
Jan 12, 2026
Merged

Use longer lifetime in clap_lex ParsedArg#6221
epage merged 1 commit intoclap-rs:masterfrom
sffc:lex-lifetime

Conversation

@sffc
Copy link
Contributor

@sffc sffc commented Jan 11, 2026

It seems that we can return 's lifetimes here. It allows for easier zero-copy args parsing, i.e., writing an args parser with a signature such as

fn parse_args<'s>(args: &'s RawArgs) -> Cli<'s> { ... }

Currently args.next() returns ParsedArg<'s>, but ParsedArg::to_value_os(&'x self) returns &'x OsStr when it can return &'s OsStr.

@sffc sffc force-pushed the lex-lifetime branch 3 times, most recently from 5519469 to f1a2ea3 Compare January 11, 2026 23:27
@epage epage merged commit 8e75826 into clap-rs:master Jan 12, 2026
25 checks passed
@sffc sffc deleted the lex-lifetime branch January 13, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants