Update docs #205

This commit is contained in:
Sunli 2020-07-08 15:05:38 +08:00
parent 2dde8b4aa6
commit 003e7bfb21
2 changed files with 40 additions and 0 deletions

View File

@ -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!()
}
}
```

View File

@ -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!()
}
}
```