-
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.
Merge pull request #54 from auto-impl-rs/sized-self-bounds
Add `Self` bounds from methods and `?Sized` relaxation (if possible) to impl header
- Loading branch information
Showing
9 changed files
with
266 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,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>(); | ||
} |
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,17 @@ | ||
use auto_impl::auto_impl; | ||
|
||
|
||
#[auto_impl(Box)] | ||
trait Foo: Sized { | ||
fn foo(&self); | ||
} | ||
|
||
#[auto_impl(Box)] | ||
trait Bar where Self: Sized { | ||
fn foo(&self); | ||
} | ||
|
||
#[auto_impl(Box)] | ||
trait Baz: Sized where Self: Sized { | ||
fn foo(&self); | ||
} |
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); | ||
} |