Skip to content

Feature request: Generate type definition from struct or enum literal #13703

Open
@jplatte

Description

@jplatte

It would be really nice for quick prototyping if there was an assist that could generate a struct or enum definition given a corresponding literal with an undefined type name at the front.

Record struct:

let foo = Foo$0 { field: "hello".to_owned() };

// generate type definition
struct Foo {
    field: String,
}

Tuple struct:

let foo = Foo$0("world");

// generate type definition
struct Foo<'a>(&'a str);

Enum:

let bar = Foo$0::Bar;
let baz = Foo::Baz;

// generate type definition
enum Foo {
    Bar,
    Baz,
}

(and equivalent for enums with tuple or record fields)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-assistsC-featureCategory: feature requestS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions