diff --git a/docs/en/src/define_complex_object.md b/docs/en/src/define_complex_object.md index 7893c128..2590eac1 100644 --- a/docs/en/src/define_complex_object.md +++ b/docs/en/src/define_complex_object.md @@ -33,3 +33,23 @@ impl MyObject { } } ``` + +## Implement Object multiple times for the same type + +Usually we can create multiple implementations for the same type in Rust, but due to the limitation of procedural macros, we can not create multiple Object implementations for the same type. For example, the following code will fail to compile. + +```rust +#[Object] +impl MyObject { + async fn field1(&self) -> i32 { + todo!() + } +} + +#[Object] +impl MyObject { + async fn field2(&self) -> i32 { + todo!() + } +} +``` diff --git a/docs/zh-CN/src/define_complex_object.md b/docs/zh-CN/src/define_complex_object.md index d8af5d75..b1478b7c 100644 --- a/docs/zh-CN/src/define_complex_object.md +++ b/docs/zh-CN/src/define_complex_object.md @@ -31,3 +31,23 @@ impl MyObject { } } ``` + +## 为同一类型实现多次Object + +通常我们在Rust中可以为同一类型创建多个实现,但由于过程宏的限制,无法为同一个类型创建多个Object实现。例如,下面的代码将无法通过编译。 + +```rust +#[Object] +impl MyObject { + async fn field1(&self) -> i32 { + todo!() + } +} + +#[Object] +impl MyObject { + async fn field2(&self) -> i32 { + todo!() + } +} +```