Skip to content

Support struct expression shorthand field #20830

@A4-Tacks

Description

@A4-Tacks

Fields with the same type and name use the 'shorthand' syntax

Example

struct Foo { bar: bool, n: i32 }

fn baz() {
    let bar = true;
    let foo: Foo = Fo$0;
}

Current:

struct Foo { bar: bool, n: i32 }

fn baz() {
    let bar = true;
    let foo: Foo = Foo { bar: ${1:()}, n: ${2:()} }$0;
}

Expect:

struct Foo { bar: bool, n: i32 }

fn baz() {
    let bar = true;
    let foo: Foo = Foo { bar$1, n: ${2:()} }$0;
}

@rustbot label +A-completion

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