[Enhancement]: must_use_xor
to Force Using One of the Functions but not all in a Struct
#128264
Labels
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
Hello,
I would like to propose a new macro,
must_use_xor
, similar to the existingmust_use
macro. This macro would ensure that users are required to invoke at least one of the functions annotated with it in a struct.Rationale
The
must_use
macro is effective for ensuring that certain return values are not ignored, but it doesn't enforce that a choice between multiple functions is made. Themust_use_xor
macro would address this by enforcing that at least one of the annotated functions must be called, thus ensuring critical functionality is utilized.Example
Additional Context
I have recently come across the need for such a macro to enforce the Anchor client to call either
signer
orsigners
: coral-xyz/anchor#3116. However, one of the maintainers currently prefers using onlysigners
as it aligns with the ts client, so there is no need for this macro in that context. Nevertheless, it would be beneficial to introduce such a macro for future use cases where enforcing the use of one among several critical functions is necessary.Thanks for considering this feature request. I believe
must_use_xor
would be a valuable addition to the Rust language.Best!
The text was updated successfully, but these errors were encountered: