Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support parsing smart pointers #4989

Open
2 tasks done
KSXGitHub opened this issue Jun 27, 2023 · 1 comment
Open
2 tasks done

Support parsing smart pointers #4989

KSXGitHub opened this issue Jun 27, 2023 · 1 comment
Labels
A-derive Area: #[derive]` macro API C-enhancement Category: Raise on the bar on expectations

Comments

@KSXGitHub
Copy link

KSXGitHub commented Jun 27, 2023

Please complete the following tasks

Clap Version

4.3.8

Describe your use case

Box of an unsized type is often smaller than its owned counterpart. And it is cheaper to clone Rc and Arc than cloning the owned version.

Describe the solution you'd like

Allow parsing arguments directly to smart pointer types such as Box, Rc, and Arc. For example:

#[derive(Clone, Parser)]
struct Args {
    #[clap(long, short)]
    tag: Arc<[Box<str>]>, // instead of Vec<String>
    files: Arc<[Box<Path>]>, // instead of Vec<PathBuf>
}

Alternatives, if applicable

No response

Additional Context

No response

@KSXGitHub KSXGitHub added the C-enhancement Category: Raise on the bar on expectations label Jun 27, 2023
@epage
Copy link
Member

epage commented Jun 27, 2023

#4626 is a more general re-evaluation of how we infer meaning from types

@epage epage added the A-derive Area: #[derive]` macro API label Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-derive Area: #[derive]` macro API C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

2 participants