aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md12
1 files changed, 10 insertions, 2 deletions
diff --git a/README.md b/README.md
index 967738e..972f82c 100644
--- a/README.md
+++ b/README.md
@@ -78,6 +78,14 @@ in `E` need to be mapped with `map_err()`. Dynamize also understands
options and results, so e.g. `Result<Option<Self::Item>, Self::Error>` also
just works.
+The destination type of an associated type is
+determined by looking at its first trait bound:
+
+* `Into<T>` is mapped to `T`
+
+* `SomeTrait` is mapped to `Box<dyn SomeTrait>`
+ (for this `SomeTrait` of course needs to be object-safe)
+
## Dynamize supports async
Dynamize supports async out of the box. Since Rust however does not yet support
@@ -90,7 +98,7 @@ async functions in traits, you'll have to additionally use another library like
#[blanket_impl_attr(async_trait)]
#[async_trait]
trait Client: Sync {
- type Error: Into<SuperError>;
+ type Error: std::error::Error;
async fn get(&self, url: String) -> Result<Vec<u8>, Self::Error>;
}
@@ -109,7 +117,7 @@ The following also just works:
```rust
#[dynamize::dynamize]
trait TraitWithCallback {
- type A: Into<String>;
+ type A: SomeTrait;
fn fun_with_callback<F: Fn(Self::A)>(&self, a: F);
}