Open epage opened 2 years ago
Comment by pksunkara Tuesday Oct 19, 2021 at 19:08 GMT
Same issue as print_*_help
and write_*_help
methods. I wanted them to be non-mut but couldn't find a way to do it without quickly blowing up the scope of it. IIRC there were some discussions around this when those signatures were implemented which might be useful here.
Comment by epage Tuesday Oct 19, 2021 at 19:36 GMT
What are your thoughts on the proposal for solving the mut
problem?
IIRC there were some discussions around this when those signatures were implemented which might be useful here.
At least in my initial search, I found https://github.com/clap-rs/clap/pull/540 which didn't have any useful conversation on the subject.
Issue by epage Tuesday Oct 19, 2021 at 15:33 GMT Originally opened as https://github.com/clap-rs/clap/issues/2911
Please complete the following tasks
Rust Version
rustc 1.55.0 (c8dfcfe04 2021-09-06)
Clap Version
master
Minimal reproducible code
Steps to reproduce the bug with the above code
Program with the
&mut
APIActual Behaviour
Its awkward and exposing of implementation details. I've seen user confusion akin to "Why does rendering need to modify the app?"
Other uses of this API, like
clap_generate
, need to use the hidden_build
Expected Behaviour
The types are clean and understandable for a user without ambiguous "modify after build"
Additional Context
I propose we add a
struct AppParser
that derefs toApp
.get_matches
will consumeApp
and use_build
(only build what is needed for parsing)App::build(self) -> AppParser
will call_build_all
&mut
functions, but without themut
We can implement the additions without breaking behavior; we just add deprecations. Then on the next breaking release, we remove the deprecated behavior.
Debug Output
No response