From 8e17844f803b40aad8eb5d21b37190cf448eb7d1 Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Sun, 3 Mar 2024 16:51:10 +0100 Subject: [PATCH] Add tests for return types of associated functions --- .../successes/assoc_function_rettype.rs | 21 +++++++++++++++++++ .../successes/assoc_function_rettype.rs | 19 +++++++++++++++++ .../successes/assoc_function_rettype.rs | 19 +++++++++++++++++ .../successes/assoc_function_rettype.rs | 21 +++++++++++++++++++ .../successes/assoc_function_rettype.rs | 19 +++++++++++++++++ 5 files changed, 99 insertions(+) create mode 100644 tests/derive_arc/successes/assoc_function_rettype.rs create mode 100644 tests/derive_box/successes/assoc_function_rettype.rs create mode 100644 tests/derive_mut/successes/assoc_function_rettype.rs create mode 100644 tests/derive_rc/successes/assoc_function_rettype.rs create mode 100644 tests/derive_ref/successes/assoc_function_rettype.rs diff --git a/tests/derive_arc/successes/assoc_function_rettype.rs b/tests/derive_arc/successes/assoc_function_rettype.rs new file mode 100644 index 0000000..ccf14d7 --- /dev/null +++ b/tests/derive_arc/successes/assoc_function_rettype.rs @@ -0,0 +1,21 @@ +use blanket::blanket; +use impls::impls; + +use std::sync::Arc; + +#[blanket(derive(Arc))] +pub trait StaticChecker { + fn check() -> Result<(), String>; +} + +#[derive(Default)] +struct NoOpChecker; + +impl StaticChecker for NoOpChecker { + fn check() -> Result<(), String> { Ok(()) } +} + +fn main() { + assert!(impls!( NoOpChecker: StaticChecker)); + assert!(impls!(Arc: StaticChecker)); +} diff --git a/tests/derive_box/successes/assoc_function_rettype.rs b/tests/derive_box/successes/assoc_function_rettype.rs new file mode 100644 index 0000000..b06e0a5 --- /dev/null +++ b/tests/derive_box/successes/assoc_function_rettype.rs @@ -0,0 +1,19 @@ +use blanket::blanket; +use impls::impls; + +#[blanket(derive(Box))] +pub trait StaticChecker { + fn check() -> Result<(), String>; +} + +#[derive(Default)] +struct NoOpChecker; + +impl StaticChecker for NoOpChecker { + fn check() -> Result<(), String> { Ok(()) } +} + +fn main() { + assert!(impls!( NoOpChecker: StaticChecker)); + assert!(impls!(Box: StaticChecker)); +} diff --git a/tests/derive_mut/successes/assoc_function_rettype.rs b/tests/derive_mut/successes/assoc_function_rettype.rs new file mode 100644 index 0000000..1bb8fa3 --- /dev/null +++ b/tests/derive_mut/successes/assoc_function_rettype.rs @@ -0,0 +1,19 @@ +use blanket::blanket; +use impls::impls; + +#[blanket(derive(Mut))] +pub trait StaticChecker { + fn check() -> Result<(), String>; +} + +#[derive(Default)] +struct NoOpChecker; + +impl StaticChecker for NoOpChecker { + fn check() -> Result<(), String> { Ok(()) } +} + +fn main() { + assert!(impls!( NoOpChecker: StaticChecker)); + assert!(impls!(&mut NoOpChecker: StaticChecker)); +} diff --git a/tests/derive_rc/successes/assoc_function_rettype.rs b/tests/derive_rc/successes/assoc_function_rettype.rs new file mode 100644 index 0000000..5625247 --- /dev/null +++ b/tests/derive_rc/successes/assoc_function_rettype.rs @@ -0,0 +1,21 @@ +use blanket::blanket; +use impls::impls; + +use std::rc::Rc; + +#[blanket(derive(Rc))] +pub trait StaticChecker { + fn check() -> Result<(), String>; +} + +#[derive(Default)] +struct NoOpChecker; + +impl StaticChecker for NoOpChecker { + fn check() -> Result<(), String> { Ok(()) } +} + +fn main() { + assert!(impls!( NoOpChecker: StaticChecker)); + assert!(impls!(Rc: StaticChecker)); +} diff --git a/tests/derive_ref/successes/assoc_function_rettype.rs b/tests/derive_ref/successes/assoc_function_rettype.rs new file mode 100644 index 0000000..fd5dca5 --- /dev/null +++ b/tests/derive_ref/successes/assoc_function_rettype.rs @@ -0,0 +1,19 @@ +use blanket::blanket; +use impls::impls; + +#[blanket(derive(Ref))] +pub trait StaticChecker { + fn check() -> Result<(), String>; +} + +#[derive(Default)] +struct NoOpChecker; + +impl StaticChecker for NoOpChecker { + fn check() -> Result<(), String> { Ok(()) } +} + +fn main() { + assert!(impls!( NoOpChecker: StaticChecker)); + assert!(impls!(&NoOpChecker: StaticChecker)); +}