print_help() et al. are conceptually read-only ops and should not take &mut self #2218
Labels
A-builder
Area: Builder API
C-bug
Category: Updating dependencies
S-duplicate
Status: Closed as Duplicate
print_help()
and other similar variants conceptually just print information to some output based on the already-configuredApp
, and therefore it is quite unexpected for them to be mutating theApp
and take a&mut self
reference. For a typical command-line tool which might want to print-help-and-exit deeper inside the program due to other errors not directly handled byclap
's argument validation, this forcesApp
to be passed by&mut self
everywhere for no good apparent reason, and thereby makes other unrelated parts of the code more complex.I looked at the implementation, and it seems this is due to some "propagation of globals and settings", which I understand to be lazy operations which need to be done once and could have been done at another time and/or because they are conceptually not mutating the app should be hidden behind a
&self
read-only reference. I might be wrong here, as I am noclap
expert, but I see no good argument from a user standpoint as to why a print function would mutate anything.Version
Actual Behavior Summary
Expected Behavior Summary
The text was updated successfully, but these errors were encountered: