Generate delegate trait
This commit is contained in:
parent
fcfc6afe05
commit
8123a39c82
1064
crates/ide-assists/src/handlers/generate_delegate_trait.rs
Normal file
1064
crates/ide-assists/src/handlers/generate_delegate_trait.rs
Normal file
File diff suppressed because it is too large
Load Diff
@ -145,6 +145,7 @@ mod handlers {
|
|||||||
mod generate_constant;
|
mod generate_constant;
|
||||||
mod generate_default_from_enum_variant;
|
mod generate_default_from_enum_variant;
|
||||||
mod generate_default_from_new;
|
mod generate_default_from_new;
|
||||||
|
mod generate_delegate_trait;
|
||||||
mod generate_deref;
|
mod generate_deref;
|
||||||
mod generate_derive;
|
mod generate_derive;
|
||||||
mod generate_documentation_template;
|
mod generate_documentation_template;
|
||||||
@ -251,6 +252,7 @@ pub(crate) fn all() -> &'static [Handler] {
|
|||||||
generate_constant::generate_constant,
|
generate_constant::generate_constant,
|
||||||
generate_default_from_enum_variant::generate_default_from_enum_variant,
|
generate_default_from_enum_variant::generate_default_from_enum_variant,
|
||||||
generate_default_from_new::generate_default_from_new,
|
generate_default_from_new::generate_default_from_new,
|
||||||
|
generate_delegate_trait::generate_delegate_trait,
|
||||||
generate_derive::generate_derive,
|
generate_derive::generate_derive,
|
||||||
generate_documentation_template::generate_documentation_template,
|
generate_documentation_template::generate_documentation_template,
|
||||||
generate_documentation_template::generate_doc_example,
|
generate_documentation_template::generate_doc_example,
|
||||||
|
@ -1015,6 +1015,69 @@ impl Person {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn doctest_generate_delegate_trait() {
|
||||||
|
check_doc_test(
|
||||||
|
"generate_delegate_trait",
|
||||||
|
r#####"
|
||||||
|
trait SomeTrait {
|
||||||
|
type T;
|
||||||
|
fn fn_(arg: u32) -> u32;
|
||||||
|
fn method_(&mut self) -> bool;
|
||||||
|
}
|
||||||
|
struct A;
|
||||||
|
impl SomeTrait for A {
|
||||||
|
type T = u32;
|
||||||
|
|
||||||
|
fn fn_(arg: u32) -> u32 {
|
||||||
|
42
|
||||||
|
}
|
||||||
|
|
||||||
|
fn method_(&mut self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
struct B {
|
||||||
|
a$0: A,
|
||||||
|
}
|
||||||
|
"#####,
|
||||||
|
r#####"
|
||||||
|
trait SomeTrait {
|
||||||
|
type T;
|
||||||
|
fn fn_(arg: u32) -> u32;
|
||||||
|
fn method_(&mut self) -> bool;
|
||||||
|
}
|
||||||
|
struct A;
|
||||||
|
impl SomeTrait for A {
|
||||||
|
type T = u32;
|
||||||
|
|
||||||
|
fn fn_(arg: u32) -> u32 {
|
||||||
|
42
|
||||||
|
}
|
||||||
|
|
||||||
|
fn method_(&mut self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
struct B {
|
||||||
|
a: A,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SomeTrait for B {
|
||||||
|
type T = <A as SomeTrait>::T;
|
||||||
|
|
||||||
|
fn fn_(arg: u32) -> u32 {
|
||||||
|
<A as SomeTrait>::fn_(arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn method_(&mut self) -> bool {
|
||||||
|
<A as SomeTrait>::method_( &mut self.a )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#####,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn doctest_generate_deref() {
|
fn doctest_generate_deref() {
|
||||||
check_doc_test(
|
check_doc_test(
|
||||||
|
Loading…
Reference in New Issue
Block a user