Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add primitive conversions submodules to the prelude #6105

Merged
merged 5 commits into from
Jun 11, 2024
Merged

Conversation

bitzoic
Copy link
Member

@bitzoic bitzoic commented Jun 10, 2024

Description

As part of #6087, it was revealed that the current use std::primitive_conversions::*; line in the prelude does not import anything which a developer can use. To use any of the submodules in the primitive conversions library, users would need to import the individual submodule regardless of the prelude.

This PR adds the submodules as an import to the prelude to stay consistent with the original intent. Both the core's and std-lib's primitive conversions modules are imported. Conversions between primitive types should not require additional imports.

Example before:

use std::primitive_conversions::u32::*;

fn foo() {
    let my_u8 = 1_u8;
    let my_u16 = 1_u16;
    let my_u64 = 1_u64;

    let u32_1 = u32::from(my_u8);
    let u32_2 = u32::from(my_u16);
    let u32_3 = u32::try_from(my_u64);
}

Example after:

fn foo() {
    let my_u8 = 1_u8;
    let my_u16 = 1_u16;
    let my_u64 = 1_u64;

    let u32_1 = u32::from(my_u8);
    let u32_2 = u32::from(my_u16);
    let u32_3 = u32::try_from(my_u64);
}

Closes #6088

Dependent on #6087

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@bitzoic bitzoic added the lib: std Standard library label Jun 10, 2024
@bitzoic bitzoic self-assigned this Jun 10, 2024
@bitzoic bitzoic requested review from a team as code owners June 10, 2024 08:58
@bitzoic bitzoic linked an issue Jun 10, 2024 that may be closed by this pull request
@bitzoic bitzoic requested review from a team as code owners June 10, 2024 09:05
@IGI-111 IGI-111 merged commit 2984831 into master Jun 11, 2024
41 checks passed
@IGI-111 IGI-111 deleted the bitzoic-6088 branch June 11, 2024 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib: std Standard library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove primitive_conversions import from the prelude
4 participants