diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -72,12 +72,13 @@ automatically also implements `DynClient`! ## How does this actually work? The destination type of an associated type is -determined by looking at its first trait bound: +determined by looking at its trait bounds: -* `Into<T>` is mapped to `T` +* if the first trait bound is `Into<T>` the destination type is `T` -* `SomeTrait` is mapped to `Box<dyn SomeTrait>` - (for this `SomeTrait` of course needs to be object-safe) +* otherwise the destination type is the boxed trait object of all trait bounds + e.g. `Error + Send` becomes `Box<dyn Error + Send>` + (for this the first trait bound needs to be object-safe) Dynamize can convert associated types in: @@ -132,7 +133,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: std::error::Error; + type Error: std::error::Error + Send; async fn get(&self, url: String) -> Result<Vec<u8>, Self::Error>; } |