diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/doctests.md | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/tests/doctests.md b/tests/doctests.md index ef557fe..3318dba 100644 --- a/tests/doctests.md +++ b/tests/doctests.md @@ -1,4 +1,4 @@ -Tests that the object-safety assertion via `impl dyn` is working: +## If the dynamized trait isn't object safe you get a compile error ```rust compile_fail trait ObjectUnsafe: Sized {} @@ -17,3 +17,40 @@ trait Trait { fn f(&self) -> Self::A; } ``` + +## Same-named method generics must have same trait bounds + +Works: + +```rust +#[dynamize::dynamize] +trait Trait { + type A: std::error::Error; + + fn a<A: std::fmt::Display>(&self, a: A) -> Self::A; + fn b<A: std::fmt::Display>(&self, a: A) -> Self::A; +} +``` + +```rust +#[dynamize::dynamize] +trait Trait { + type A: std::error::Error; + + fn a<A>(&self, a: A) -> Self::A; + fn b<B: std::fmt::Display>(&self, a: B) -> Self::A; +} +``` + + +Fails: + +```rust compile_fail +#[dynamize::dynamize] +trait Trait { + type A: std::error::Error; + + fn a<A>(&self, a: A) -> Self::A; + fn b<A: std::fmt::Display>(&self, a: A) -> Self::A; +} +``` |