aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/README.md b/README.md
index 6051fb5..555e7f1 100644
--- a/README.md
+++ b/README.md
@@ -147,3 +147,29 @@ trait Client: Sync {
Note that it is important that the `#[dynamize]` attribute comes before the
`#[async_trait]` attribute, since dynamize must run before async_trait.
+
+## Using dynamize with other collections
+
+Dynamize automatically recognizes collections from the standard library like
+`Vec<_>` and `HashMap<_, _>`. Dynamize can also work with other collection
+types as long as they implement `IntoIterator` and `FromIterator`, for example
+dynamize can be used with [indexmap](https://crates.io/crates/indexmap) as
+follows:
+
+```rust ignore
+#[dynamize::dynamize]
+#[collection(IndexMap, 2)]
+trait Trait {
+ type A: Into<String>;
+ type B: Into<i32>;
+
+ fn example(&self) -> IndexMap<Self::A, Self::B>;
+}
+```
+
+The passed number tells dynamize how many generic type parameters to expect.
+
+* for 1 dynamize expects: `Type<A>: IntoIterator<Item=A> + FromIterator<A>`
+* for 2 dynamize expects: `Type<A,B>: IntoIterator<Item=(A,B)> + FromIterator<(A,B)>`
+* for 3 dynamize expects: `Type<A,B,C>: IntoIterator<Item=(A,B,C)> + FromIterator<(A,B,C)>`
+* etc ...