rust-refactor icon indicating copy to clipboard operation
rust-refactor copied to clipboard

Extract enum variant

Open nrc opened this issue 10 years ago • 0 comments

Most useful for structs, the tuple case is not so important. E.g.,

enum Foo {
    Foo,
    Bar { a: A, b: B },
    Baz(A, B)
}

to

enum Foo {
    Foo,
    Bar(Bar),
    Baz(Baz)
}

pub struct Bar {
    a: A,
    b: B,
}

type Baz = (A, B);

I guess there should be a collapse case too, but that seems less useful. The fun part of this will be getting the pattern matching right.

nrc avatar Oct 07 '15 01:10 nrc