Skip to content

Commit

Permalink
Add tests for return types of associated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed Mar 3, 2024
1 parent 1851c1f commit 8e17844
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/derive_arc/successes/assoc_function_rettype.rs
Original file line number Diff line number Diff line change
@@ -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<NoOpChecker>: StaticChecker));
}
19 changes: 19 additions & 0 deletions tests/derive_box/successes/assoc_function_rettype.rs
Original file line number Diff line number Diff line change
@@ -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<NoOpChecker>: StaticChecker));
}
19 changes: 19 additions & 0 deletions tests/derive_mut/successes/assoc_function_rettype.rs
Original file line number Diff line number Diff line change
@@ -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));
}
21 changes: 21 additions & 0 deletions tests/derive_rc/successes/assoc_function_rettype.rs
Original file line number Diff line number Diff line change
@@ -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<NoOpChecker>: StaticChecker));
}
19 changes: 19 additions & 0 deletions tests/derive_ref/successes/assoc_function_rettype.rs
Original file line number Diff line number Diff line change
@@ -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));
}

0 comments on commit 8e17844

Please sign in to comment.