Add Isize and Usize IntKinds for use in ParseCallbacks::int_macro#3366
Open
TheJokr wants to merge 1 commit intorust-lang:mainfrom
Open
Add Isize and Usize IntKinds for use in ParseCallbacks::int_macro#3366TheJokr wants to merge 1 commit intorust-lang:mainfrom
TheJokr wants to merge 1 commit intorust-lang:mainfrom
Conversation
C macros are often used to define array/buffer size constants. In Rust, representing these as `usize` is more natural than the fixed-bit-size integer types, because it allows indexing and comparisons without casting. I also added `isize` while I was at it. Using these types is already possible via `IntKind::Custom`, but given they are built-in integer types like `u64` and `i64`, I figured having a separate enum variant would be appropriate.
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.
C macros are often used to define array/buffer size constants. In Rust, representing these as
usizeis more natural than the fixed-bit-size integer types, because it allows indexing and comparisons without casting.I also added
isizewhile I was at it. Using these types is already possible viaIntKind::Custom, but given they are built-in integer types likeu64andi64, I figured having a separate enum variant would be appropriate.