-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for
Self
bounds on methods and add those bounds to impl header
See #11
- Loading branch information
1 parent
82bf029
commit cf6c9cc
Showing
4 changed files
with
112 additions
and
2 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
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,23 @@ | ||
use auto_impl::auto_impl; | ||
|
||
|
||
#[auto_impl(&)] | ||
trait Trait { | ||
fn foo(&self) | ||
where Self: Clone; | ||
} | ||
|
||
#[derive(Clone)] | ||
struct Foo {} | ||
impl Trait for Foo { | ||
fn foo(&self) | ||
where Self: Clone, | ||
{} | ||
} | ||
|
||
fn assert_impl<T: Trait>() {} | ||
|
||
fn main() { | ||
assert_impl::<Foo>(); | ||
assert_impl::<&Foo>(); | ||
} |
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,24 @@ | ||
use auto_impl::auto_impl; | ||
|
||
|
||
#[auto_impl(Box)] | ||
trait Trait { | ||
fn bar(&self); | ||
|
||
#[auto_impl(keep_default_for(Box))] | ||
fn foo(&self) | ||
where Self: Clone | ||
{} | ||
} | ||
|
||
fn assert_impl<T: Trait>() {} | ||
|
||
struct Foo {} | ||
impl Trait for Foo { | ||
fn bar(&self) {} | ||
} | ||
|
||
fn main() { | ||
assert_impl::<Foo>(); | ||
assert_impl::<Box<Foo>>(); | ||
} |
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,35 @@ | ||
use std::fmt; | ||
use auto_impl::auto_impl; | ||
|
||
|
||
#[auto_impl(&)] | ||
trait Trait { | ||
fn foo(&self) | ||
where Self: Clone; | ||
fn bar(&self) | ||
where Self: Default + fmt::Display; | ||
} | ||
|
||
#[derive(Clone, Default)] | ||
struct Foo {} | ||
impl Trait for Foo { | ||
fn foo(&self) | ||
where Self: Clone, | ||
{} | ||
fn bar(&self) | ||
where Self: Default + fmt::Display, | ||
{} | ||
} | ||
|
||
impl fmt::Display for Foo { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
fn assert_impl<T: Trait>() {} | ||
|
||
fn main() { | ||
assert_impl::<Foo>(); | ||
assert_impl::<&Foo>(); | ||
} |