diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-25 10:30:54 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-11-26 11:45:53 +0100 |
commit | 7489a3c2246e7ea2483446dd2ed3fdbfaf462c1a (patch) | |
tree | fc2670f56f7cc16567eb10d88f9439abb9098298 /tests | |
parent | 43950edc4f26a07055fb917fa8bbb262276e2a08 (diff) |
introduce #[convert] attribute
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index b75c605..11bf10d 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -297,3 +297,22 @@ trait OneTrait: SomeTrait { fn test(&self) -> Self::X; } + +struct SuperError; +trait Cache {} +#[dynamize::dynamize] +trait Client { + type Error: Into<SuperError>; + + fn get(&self, url: String) -> Result<Vec<u8>, Self::Error>; +} +#[dynamize::dynamize] +#[dynamized(Client)] +#[convert = |x: <Self as Client>::Error| -> SuperError {x.into()}] +trait ClientWithCache: Client { + fn get_with_cache<C: Cache>( + &self, + url: String, + cache: C, + ) -> Result<Vec<u8>, <Self as Client>::Error>; +} |