feat: Automatically coerce bools to numbers#1355
Open
Kn4ughty wants to merge 4 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
If parsing a DynVal as a number (f64, i64, i32) fails, try to convert to a bool, then return 0 or 1 respectively.
fixes #1353
Usage
This script takes in 1 or 0 to control whether the todo is checked.
:onclick~/.scripts/todo.py update --id=${id} --checked=${!done*1}`I could just modify the script but there is probably other uses for different logic.
Additional Notes
I think the as_ functions could be made into a macro like how it is with impl_dynval_from.
It should probably go in the documentation somewhere. I was thinking just under the "simple mathematical operations" dot point but I'm not sure.
Checklist
Please make sure you can check all the boxes that apply to this PR.
docs/content/maindirectory has been adjusted to reflect my changes.cargo fmtto automatically format all code before committing