Skip to content
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
to-code-fixed-const
Mar 26, 2025
Merged

src/lib.rs: Mark Isrc::to_code_fixed() as const#3
simnalamburt merged 1 commit intomainfrom
to-code-fixed-const

Conversation

@simnalamburt
Copy link
Copy Markdown
Member

No description provided.

@simnalamburt simnalamburt requested a review from Copilot March 26, 2025 07:22
@simnalamburt simnalamburt self-assigned this Mar 26, 2025
@simnalamburt simnalamburt merged commit e23cf70 into main Mar 26, 2025
2 checks passed
@simnalamburt simnalamburt deleted the to-code-fixed-const branch March 26, 2025 07:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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] {
Copy link

Copilot AI Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants