aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-19 11:49:22 +0100
committerMartin Fischer <martin@push-f.com>2021-11-19 12:09:55 +0100
commit323762d238ebb9d9b8fa65bd1290aaa39648615c (patch)
treebba4645bf2fef6307018fe9187a19687149cbfbd /tests
parenta11255acdf3b3fac12d8f51048f0bed2c0df8a11 (diff)
if first type bound isn't Into<T> auto-box it
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index 4d09847..652be48 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -152,3 +152,28 @@ trait AsyncWithCallback: Sync {
async fn test1(&self) -> Self::A;
async fn fun_with_callback<F: Fn(Self::A) + Sync + Send + 'static>(&self, a: F);
}
+
+#[dynamize::dynamize]
+trait TypeTraitBound {
+ type A: std::error::Error;
+
+ fn foobar(&self, text: &str) -> Result<i32, Self::A>;
+}
+
+fn type_trait_bound_test<T: TypeTraitBound>(t: T) {
+ let dyn_trait: &dyn DynTypeTraitBound = &t;
+ let _: Result<i32, Box<dyn std::error::Error>> = dyn_trait.foobar("test");
+}
+
+#[dynamize::dynamize]
+trait TypeTraitBoundStatic {
+ type A: std::error::Error + 'static;
+
+ fn foobar(&self, text: &str) -> Result<i32, Self::A>;
+}
+
+fn type_trait_bound_static_test(
+ t: Box<dyn DynTypeTraitBoundStatic>,
+) -> Option<Box<dyn std::error::Error>> {
+ t.foobar("test").err()
+}