-
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.
Add
?Sized
relaxation to impl header whenever possible
It's only impossible when there is `Self` by value in in parameter or return position in any method. This commit does not yet check for `Self` in non-receiver parameters as this crate cannot deal with that yet anyway. Furthermore, a `where Self: Sized` bound on methods does not help in that we still cannot add the `?Sized` relaxation. This is related to issue #11.
- Loading branch information
1 parent
52b3794
commit 82bf029
Showing
5 changed files
with
139 additions
and
5 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,13 @@ | ||
use auto_impl::auto_impl; | ||
|
||
|
||
#[auto_impl(Box)] | ||
trait Trait { | ||
fn foo(self); | ||
} | ||
|
||
fn assert_impl<T: Trait>() {} | ||
|
||
fn main() { | ||
assert_impl::<Box<dyn Trait>>(); | ||
} |
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,22 @@ | ||
use auto_impl::auto_impl; | ||
|
||
|
||
#[auto_impl(Box)] | ||
trait Trait { | ||
fn bar(&self); | ||
|
||
#[auto_impl(keep_default_for(Box))] | ||
fn foo(self) where Self: Sized {} | ||
} | ||
|
||
fn assert_impl<T: Trait>() {} | ||
|
||
struct Foo {} | ||
impl Trait for Foo { | ||
fn bar(&self) {} | ||
} | ||
|
||
fn main() { | ||
assert_impl::<Foo>(); | ||
assert_impl::<Box<dyn Trait>>(); | ||
} |
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 auto_impl::auto_impl; | ||
|
||
|
||
#[auto_impl(&, &mut, Box, Rc, Arc)] | ||
trait Trait { | ||
fn foo(&self); | ||
} | ||
|
||
fn assert_impl<T: Trait>() {} | ||
|
||
fn main() { | ||
use std::{rc::Rc, sync::Arc}; | ||
|
||
assert_impl::<&dyn Trait>(); | ||
assert_impl::<&mut dyn Trait>(); | ||
assert_impl::<Box<dyn Trait>>(); | ||
assert_impl::<Rc<dyn Trait>>(); | ||
assert_impl::<Arc<dyn Trait>>(); | ||
} |
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,7 @@ | ||
use auto_impl::auto_impl; | ||
|
||
|
||
#[auto_impl(Box)] | ||
trait Trait { | ||
fn foo(self); | ||
} |