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

Assist to derive `type alias = signature` for a function

Open Veykril opened this issue 1 year ago • 1 comments

Given some function

unsafe fn foo(param: u32) -> String { ... }

with the cursor on foo we should offer an assist that generates a type alias for the function's signature

type FooFn = unsafe fn(u32) -> String;

Veykril avatar Oct 19 '24 16:10 Veykril

@rustbot claim

Giga-Bowser avatar Oct 22 '24 00:10 Giga-Bowser

with the cursor on foo we should offer an assist that generates a type alias for the function's signature

type FooFn = unsafe fn(u32) -> String;

Any reason in particular not to use named params? As in:

type FooFn = unsafe fn(param: u32) -> String;

Giga-Bowser avatar Oct 22 '24 12:10 Giga-Bowser

We could offer both actually (forgot param names are legal in that position), so a grouped assist that has an assist each to generate either, with or without params.

(additionally once trait aliases are stable we could offer a third option to generate trait FooFn = Fn(u32) -> String; etc)

Veykril avatar Oct 22 '24 12:10 Veykril