Update docs #205
This commit is contained in:
parent
2dde8b4aa6
commit
003e7bfb21
|
@ -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!()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
@ -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!()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue
Block a user