[Variant] Add as_u* for Variant#8284
Merged
alamb merged 3 commits intoapache:mainfrom Sep 5, 2025
Merged
Conversation
Member
Author
|
@alamb Please help review this when you're free, thanks. |
alamb
approved these changes
Sep 5, 2025
| /// let v1 = Variant::from(123i64); | ||
| /// assert_eq!(v1.as_u8(), Some(123u8)); | ||
| /// | ||
| /// // but not a variant that cant fit into the range |
Contributor
There was a problem hiding this comment.
Suggested change
| /// // but not a variant that cant fit into the range | |
| /// // but not a variant that can't fit into the range |
| /// let v1 = Variant::from(123i64); | ||
| /// assert_eq!(v1.as_u16(), Some(123u16)); | ||
| /// | ||
| /// // but not a variant that cant fit into the range |
Contributor
There was a problem hiding this comment.
Suggested change
| /// // but not a variant that cant fit into the range | |
| /// // but not a variant that can't fit into the range |
| /// let v1 = Variant::from(123i64); | ||
| /// assert_eq!(v1.as_u32(), Some(123u32)); | ||
| /// | ||
| /// // but not a variant that cant fit into the range |
Contributor
There was a problem hiding this comment.
Suggested change
| /// // but not a variant that cant fit into the range | |
| /// // but not a variant that can't fit into the range |
Member
Author
|
@alamb thanks for the review, I've updated the code, please take another look. |
Contributor
|
Thanks @klion26 -- looks great to me |
scovich
approved these changes
Sep 5, 2025
Contributor
scovich
left a comment
There was a problem hiding this comment.
LGTM! The doc tests are a nice way to exercise the code (dual purpose)
Member
Author
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.
Which issue does this PR close?
Vairant::as_u*#8283.Rationale for this change
Add the
Variant::as_u*functions`Are these changes tested?
Added doc tests
Are there any user-facing changes?
No