Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add formatting support to the ensure macro #14301

Closed
liamaharon opened this issue Jun 4, 2023 · 2 comments
Closed

Add formatting support to the ensure macro #14301

liamaharon opened this issue Jun 4, 2023 · 2 comments
Labels
J0-enhancement An additional feature request.

Comments

@liamaharon
Copy link
Contributor

          Not sure if `ensure!` can do formatting.

Originally posted by @ggwpez in #14241 (comment)


Unlike assert, ensure does not support string formatting.

@liamaharon liamaharon added the J0-enhancement An additional feature request. label Jun 4, 2023
@ggwpez
Copy link
Member

ggwpez commented Jun 4, 2023

I am not sure if it ever could - since we use it in no-std and there is no format!.
Other thing is that we normally use it with DispatchError and that requires &'static str, so not even format! would help.

@bkchr
Copy link
Member

bkchr commented Jun 4, 2023

Yeah, this makes no sense. In contrast to assert, ensure doesn't take any string and thus should not support any kind of formatting. The second argument can be anything and is just the return if the check fails.

@bkchr bkchr closed this as completed Jun 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request.
Projects
None yet
Development

No branches or pull requests

3 participants