required_unless_present
different error in --release
vs --debug
mode
#5261
Replies: 1 comment 3 replies
-
To clarify one error is
and the other is
The first is a debug assert saying that an invariant was violated. The second is a user-facing error from clap trying to do the best it can despite the invariant being broken. We limit out asserts to debug asserts to improve performance, both build time and runtime. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was trying to figure out why
required_unless_present
did not work for the following code (and I saw a separate discussion that noted it was necessary to useOption<usize>
, which works), but found that the behavior of the following is different between release and debug:In debug mode:
Argument a:
requiredconflicts with
required_unless*``In release mode:
error: The following required argument was not provided: b
I think this is due to the high number of
debug_asserts
used within Clap.I think it would be better if release and debug were unified behavior, and also this may be a useful chance to show the user that they need to use
Option
for theserequired_unless_present
flags.Beta Was this translation helpful? Give feedback.
All reactions