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

Propose to add lifetime annotations

Open vanillajonathan opened this issue 4 years ago • 0 comments

When a user hovers the cursor over a method parameter, a yellow light bulb should appear that lets the user add a lifetime annotations to the method and its struct for that parameter.

From:

struct Foo {
    bar: &Bar,
}

struct Bar;

impl Foo {
    fn new(bar: &Bar) -> Self {
        Foo { bar }
    }
}

Into:

struct Foo<'a> {
    bar: &'a Bar<'a>,
}

struct Bar;

impl<'a> Foo<'a> {
    fn new(bar: &'a Bar<'a>) -> Self {
        Foo { bar }
    }
}

vanillajonathan avatar Nov 04 '20 19:11 vanillajonathan