Skip to content

Assist: extract_sub_struct #20739

@A4-Tacks

Description

@A4-Tacks
struct Foo {
    $0name: String,
    id: u32$0,
    counter: u32,
}
impl Foo {
    fn clear(&mut self) {
        self.name.clear();
        self.id = 0;
    }

    fn init_id(&mut self) {
        self.id = self.counter;
        self.counter += 1;
    }
}

->

struct NewStruct {
    name: String,
    id: u32
}

impl NewStruct {
    fn clear(&mut self) {
        self.name.clear();
        self.id = 0;
    }
}

struct Foo {
    new_struct$0: NewStruct,
    counter: u32,
}
impl Foo {
    fn init_id(&mut self) {
        self.new_struct.id = self.counter;
        self.counter += 1;
    }
}

@rustbot label +A-assists

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions