-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for return types of associated functions
- Loading branch information
Showing
5 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} |