add support for truncating string arguments#15
Merged
Conversation
Contributor
Author
|
Ah, I see there is a default precision value of 6. |
Fixes tjol#14. There is a slight issue with compatibility with glibc here, since it will happily truncate in the middle of a multi-byte character. We must instead round lengths down to the nearest character boundary, since we cannot produce rust strings that contain invalid UTF-8.
b344e19 to
2f91f29
Compare
tjol
reviewed
May 17, 2025
| force_sign: false, | ||
| width: NumericParam::Literal(0), | ||
| precision: NumericParam::Literal(6), | ||
| precision: NumericParam::FromArgument, // Placeholder - must not be returned! |
Owner
There was a problem hiding this comment.
Can't say I like this overloading of FromArgument but considering adding another variant to NumericParam would be a breaking change to the API I think I agree this is the least worst option
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.
Fixes #14.
There is a slight issue with compatibility with glibc here, since it will happily truncate in the middle of a multi-byte character. We must instead round lengths down to the nearest character boundary, since we cannot produce rust strings that contain invalid UTF-8.