rust-analyzer
rust-analyzer copied to clipboard
Add ide-assist, generate single field struct From
Close rust-lang/rust-analyzer#19696
Assist: generate_single_field_struct_from
Implement From for a single field structure, ignore trivial types.
# //- minicore: from, phantom_data
use core::marker::PhantomData;
struct $0Foo<T> {
id: i32,
_phantom_data: PhantomData<T>,
}
->
use core::marker::PhantomData;
struct Foo<T> {
id: i32,
_phantom_data: PhantomData<T>,
}
impl<T> From<i32> for Foo<T> {
fn from(id: i32) -> Self {
Self { id, _phantom_data: PhantomData }
}
}
r? @Veykril
@ShoyuVanilla Can merge this pr?
I forgot about this as I didn't have merge permission then 😅