Skip to content

Add ide-assist, generate single field struct From #19783

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

Merged
merged 1 commit into from
Jul 18, 2025

Conversation

A4-Tacks
Copy link
Contributor

@A4-Tacks A4-Tacks commented May 12, 2025

Close #19696

Assist: generate_single_field_struct_from

Implement From for a single field structure, ignore trivial types.

# //- minicore: from, phantom_data
use core::marker::PhantomData;
struct $0Foo<T> {
    id: i32,
    _phantom_data: PhantomData<T>,
}

->

use core::marker::PhantomData;
struct Foo<T> {
    id: i32,
    _phantom_data: PhantomData<T>,
}

impl<T> From<i32> for Foo<T> {
    fn from(id: i32) -> Self {
        Self { id, _phantom_data: PhantomData }
    }
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 12, 2025
@A4-Tacks A4-Tacks force-pushed the generate-single-field-from branch 3 times, most recently from 32ce5ad to 84e645d Compare May 12, 2025 22:11
@A4-Tacks
Copy link
Contributor Author

r? @Veykril

@A4-Tacks A4-Tacks changed the title feat: ide-assist, generate single field struct From Add ide-assist, generate single field struct From Jun 2, 2025
@A4-Tacks A4-Tacks force-pushed the generate-single-field-from branch from 84e645d to 3de5329 Compare June 5, 2025 04:15
Copy link
Member

@ShoyuVanilla ShoyuVanilla left a comment

Choose a reason for hiding this comment

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

Oh, this looks quite useful 👍

@Veykril Veykril removed their assignment Jun 27, 2025
@A4-Tacks
Copy link
Contributor Author

@ShoyuVanilla Can merge this pr?

@ShoyuVanilla
Copy link
Member

I forgot about this as I didn't have merge permission then 😅

@ShoyuVanilla ShoyuVanilla added this pull request to the merge queue Jul 18, 2025
Merged via the queue into rust-lang:master with commit 4f294fc Jul 18, 2025
14 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 18, 2025
@A4-Tacks A4-Tacks deleted the generate-single-field-from branch July 23, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate From impl for single field structs
4 participants