From cf68dd857cd772b47dc46731c6bbb02112f07889 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Fri, 13 Aug 2021 00:11:15 -0300 Subject: Make generics work in more places --- tests/12-combining-generics.rs | 20 ++++++++++++++++++++ tests/13-trait-generics.rs | 20 ++++++++++++++++++++ tests/progress.rs | 2 ++ 3 files changed, 42 insertions(+) create mode 100644 tests/12-combining-generics.rs create mode 100644 tests/13-trait-generics.rs (limited to 'tests') diff --git a/tests/12-combining-generics.rs b/tests/12-combining-generics.rs new file mode 100644 index 0000000..0401887 --- /dev/null +++ b/tests/12-combining-generics.rs @@ -0,0 +1,20 @@ +// Checks that the impl trait can have its own generics. + +use impl_trait::impl_trait; + +struct Foo(T); +trait Bar { +} + +impl_trait! { + impl Foo { + impl trait Bar { + } + } +} + +fn static_assert_1, U>(_t: T, _u: U) {} + +fn main() { + static_assert_1(Foo(()), ()); +} diff --git a/tests/13-trait-generics.rs b/tests/13-trait-generics.rs new file mode 100644 index 0000000..889d168 --- /dev/null +++ b/tests/13-trait-generics.rs @@ -0,0 +1,20 @@ +// Checks that the impl trait can have generics without the inherent impl having generics. + +use impl_trait::impl_trait; + +struct Foo; +trait Bar { +} + +impl_trait! { + impl Foo { + impl trait Bar { + } + } +} + +fn static_assert_1, U>(_t: T, _u: U) {} + +fn main() { + static_assert_1(Foo, ()); +} diff --git a/tests/progress.rs b/tests/progress.rs index 5a1bdb6..ef302b0 100644 --- a/tests/progress.rs +++ b/tests/progress.rs @@ -12,6 +12,8 @@ fn tests() { t.pass("tests/09-multiple-traits.rs"); t.pass("tests/10-multiple-traits-with-generics.rs"); t.pass("tests/11-traits-generics-docs.rs"); + t.pass("tests/12-combining-generics.rs"); + t.pass("tests/13-trait-generics.rs"); t.pass("tests/98-readme.rs"); t.pass("tests/99-goal.rs"); } -- cgit 1.4.1