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

Propose to refer to struct as Self

Open vanillajonathan opened this issue 4 years ago • 0 comments

A yellow light bulb should appear that proposes that the user renames the return type to Self.

From:

struct Foo {
    bar: u8,
}

impl Foo {
    fn new(bar: u8) -> Foo {
        Foo { bar }
    }
}

Into:

struct Foo {
    bar: u8,
}

impl Foo {
    fn new(bar: u8) -> Self { // Foo into Self
        Self { bar } // Foo into Self
    }
}

vanillajonathan avatar Nov 17 '20 22:11 vanillajonathan