diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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); } |