This repository was archived by the owner on Apr 18, 2025. It is now read-only.
src/lib.rs: Mark Isrc::to_code_fixed() as const#3
Merged
simnalamburt merged 1 commit intomainfrom Mar 26, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR marks the Isrc::to_code_fixed() method as const to enable compile-time evaluation of the function.
- Converts the function into a const fn
- Introduces const array initialization using MaybeUninit
Comments suppressed due to low confidence (1)
src/lib.rs:344
- The const block in the array initialization should be reviewed to ensure compatibility across targeted Rust versions. Confirm that this syntax complies with your intended constant evaluation semantics.
let mut ret = [const { MaybeUninit::<u8>::uninit() }; 12];
| /// assert_eq!(isrc.to_code_fixed(), *b"AA6Q72000047"); | ||
| /// ``` | ||
| pub fn to_code_fixed(self) -> [u8; 12] { | ||
| pub const fn to_code_fixed(self) -> [u8; 12] { |
There was a problem hiding this comment.
Marking the function as const requires that all operations within are allowed in const contexts. Verify that moving 'self' is valid here (i.e., that Isrc is Copy or that moving it doesn't introduce unintended behavior).
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
No description provided.