-
Notifications
You must be signed in to change notification settings - Fork 36
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 #1370 from YBoy-git/fix_deref_tests
READY : (derive_tools) : Fix deref_mut tests
- Loading branch information
Showing
15 changed files
with
230 additions
and
50 deletions.
There are no files selected for viewing
15 changes: 12 additions & 3 deletions
15
module/core/derive_tools/tests/inc/deref_mut/bounds_inlined.rs
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 |
---|---|---|
@@ -1,10 +1,19 @@ | ||
use core::fmt::Debug; | ||
|
||
use core::ops::{ Deref }; | ||
use derive_tools::{ Deref, DerefMut }; | ||
use core::ops::Deref; | ||
use derive_tools::DerefMut; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref, DerefMut ) ] | ||
#[ derive( DerefMut ) ] | ||
struct BoundsInlined< T : ToString, U : Debug >( T, U ); | ||
|
||
impl< T : ToString, U : Debug > Deref for BoundsInlined< T, U > | ||
{ | ||
type Target = T; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&self.0 | ||
} | ||
} | ||
|
||
include!( "./only_test/bounds_inlined.rs" ); |
17 changes: 14 additions & 3 deletions
17
module/core/derive_tools/tests/inc/deref_mut/bounds_mixed.rs
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 |
---|---|---|
@@ -1,12 +1,23 @@ | ||
use core::fmt::Debug; | ||
|
||
use core::ops::{ Deref }; | ||
use derive_tools::{ Deref, DerefMut }; | ||
use core::ops::Deref; | ||
use derive_tools::DerefMut; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref, DerefMut ) ] | ||
#[ derive( DerefMut ) ] | ||
struct BoundsMixed< T : ToString, U >( T, U ) | ||
where | ||
U : Debug; | ||
|
||
impl< T : ToString, U > Deref for BoundsMixed< T, U > | ||
where | ||
U : Debug, | ||
{ | ||
type Target = T; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&self.0 | ||
} | ||
} | ||
|
||
include!( "./only_test/bounds_mixed.rs" ); |
18 changes: 15 additions & 3 deletions
18
module/core/derive_tools/tests/inc/deref_mut/bounds_where.rs
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 |
---|---|---|
@@ -1,14 +1,26 @@ | ||
trait Trait<'a> {} | ||
impl<'a> Trait<'a> for i32 {} | ||
|
||
use core::ops::{ Deref }; | ||
use derive_tools::{ Deref, DerefMut }; | ||
use core::ops::Deref; | ||
use derive_tools::DerefMut; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref, DerefMut ) ] | ||
#[ derive( DerefMut ) ] | ||
struct BoundsWhere< T, U >( T, U ) | ||
where | ||
T : ToString, | ||
for< 'a > U : Trait< 'a >; | ||
|
||
impl< T, U > Deref for BoundsWhere< T, U > | ||
where | ||
T : ToString, | ||
for< 'a > U : Trait< 'a > | ||
{ | ||
type Target = T; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&self.0 | ||
} | ||
} | ||
|
||
include!( "./only_test/bounds_where.rs" ); |
18 changes: 15 additions & 3 deletions
18
module/core/derive_tools/tests/inc/deref_mut/enum_named.rs
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 |
---|---|---|
@@ -1,12 +1,24 @@ | ||
use core::ops::{ Deref }; | ||
use derive_tools::{ Deref, DerefMut }; | ||
use core::ops::Deref; | ||
use derive_tools::DerefMut; | ||
|
||
#[ allow( dead_code) ] | ||
#[ derive( Deref, DerefMut ) ] | ||
#[ derive( DerefMut ) ] | ||
enum EnumNamed | ||
{ | ||
A { a : String, b : i32 }, | ||
B { a : String, b : i32 }, | ||
} | ||
|
||
impl Deref for EnumNamed | ||
{ | ||
type Target = String; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
match self | ||
{ | ||
Self::A { a : v, ..} | Self::B { a : v, .. } => v | ||
} | ||
} | ||
} | ||
|
||
include!( "./only_test/enum_named.rs" ); |
18 changes: 15 additions & 3 deletions
18
module/core/derive_tools/tests/inc/deref_mut/enum_tuple.rs
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 |
---|---|---|
@@ -1,12 +1,24 @@ | ||
use core::ops::{ Deref }; | ||
use derive_tools::{ Deref, DerefMut }; | ||
use core::ops::Deref; | ||
use derive_tools::DerefMut; | ||
|
||
#[ allow( dead_code) ] | ||
#[ derive( Deref, DerefMut ) ] | ||
#[ derive( DerefMut ) ] | ||
enum EnumTuple | ||
{ | ||
A( String, i32 ), | ||
B( String, i32 ), | ||
} | ||
|
||
impl Deref for EnumTuple | ||
{ | ||
type Target = String; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
match self | ||
{ | ||
Self::A( v, .. ) | Self::B( v, .. ) => v | ||
} | ||
} | ||
} | ||
|
||
include!( "./only_test/enum_tuple.rs" ); |
15 changes: 12 additions & 3 deletions
15
module/core/derive_tools/tests/inc/deref_mut/generics_constants.rs
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 |
---|---|---|
@@ -1,8 +1,17 @@ | ||
use core::ops::{ Deref }; | ||
use derive_tools::{ Deref, DerefMut }; | ||
use core::ops::Deref; | ||
use derive_tools::{ DerefMut }; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref, DerefMut ) ] | ||
#[ derive( DerefMut ) ] | ||
struct GenericsConstants< const N : usize >( i32 ); | ||
|
||
impl< const N : usize > Deref for GenericsConstants< N > | ||
{ | ||
type Target = i32; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&self.0 | ||
} | ||
} | ||
|
||
include!( "./only_test/generics_constants.rs" ); |
15 changes: 12 additions & 3 deletions
15
module/core/derive_tools/tests/inc/deref_mut/generics_constants_default.rs
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 |
---|---|---|
@@ -1,8 +1,17 @@ | ||
use core::ops::{ Deref }; | ||
use derive_tools::{ Deref, DerefMut }; | ||
use core::ops::Deref; | ||
use derive_tools::DerefMut; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref, DerefMut ) ] | ||
#[ derive( DerefMut ) ] | ||
struct GenericsConstantsDefault< const N : usize = 0 >( i32 ); | ||
|
||
impl< const N : usize > Deref for GenericsConstantsDefault< N > | ||
{ | ||
type Target = i32; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&self.0 | ||
} | ||
} | ||
|
||
include!( "./only_test/generics_constants_default.rs" ); |
15 changes: 12 additions & 3 deletions
15
module/core/derive_tools/tests/inc/deref_mut/generics_lifetimes.rs
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 |
---|---|---|
@@ -1,8 +1,17 @@ | ||
use core::ops::{ Deref }; | ||
use derive_tools::{ Deref, DerefMut }; | ||
use core::ops::Deref; | ||
use derive_tools::DerefMut; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref, DerefMut ) ] | ||
#[ derive( DerefMut ) ] | ||
struct GenericsLifetimes< 'a >( &'a i32 ); | ||
|
||
impl< 'a > Deref for GenericsLifetimes< 'a > | ||
{ | ||
type Target = &'a i32; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&self.0 | ||
} | ||
} | ||
|
||
include!( "./only_test/generics_lifetimes.rs" ); |
15 changes: 12 additions & 3 deletions
15
module/core/derive_tools/tests/inc/deref_mut/generics_types.rs
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 |
---|---|---|
@@ -1,8 +1,17 @@ | ||
use core::ops::{ Deref }; | ||
use derive_tools::{ Deref, DerefMut }; | ||
use core::ops::Deref; | ||
use derive_tools::DerefMut; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref, DerefMut ) ] | ||
#[ derive( DerefMut ) ] | ||
struct GenericsTypes< T >( T ); | ||
|
||
impl< T > Deref for GenericsTypes< T > | ||
{ | ||
type Target = T; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&self.0 | ||
} | ||
} | ||
|
||
include!( "./only_test/generics_types.rs" ); |
15 changes: 12 additions & 3 deletions
15
module/core/derive_tools/tests/inc/deref_mut/generics_types_default.rs
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 |
---|---|---|
@@ -1,8 +1,17 @@ | ||
use core::ops::{ Deref }; | ||
use derive_tools::{ Deref, DerefMut }; | ||
use core::ops::Deref; | ||
use derive_tools::DerefMut; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive ( Deref, DerefMut ) ] | ||
#[ derive ( DerefMut ) ] | ||
struct GenericsTypesDefault< T = i32 >( T ); | ||
|
||
impl< T > Deref for GenericsTypesDefault< T > | ||
{ | ||
type Target = T; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&self.0 | ||
} | ||
} | ||
|
||
include!( "./only_test/generics_types_default.rs" ); |
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
15 changes: 12 additions & 3 deletions
15
module/core/derive_tools/tests/inc/deref_mut/struct_named.rs
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 |
---|---|---|
@@ -1,12 +1,21 @@ | ||
use core::ops::{ Deref }; | ||
use derive_tools::{ Deref, DerefMut }; | ||
use core::ops::Deref; | ||
use derive_tools::DerefMut; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref, DerefMut ) ] | ||
#[ derive( DerefMut ) ] | ||
struct StructNamed | ||
{ | ||
a : String, | ||
b : i32, | ||
} | ||
|
||
impl Deref for StructNamed | ||
{ | ||
type Target = String; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&self.a | ||
} | ||
} | ||
|
||
include!( "./only_test/struct_named.rs" ); |
15 changes: 12 additions & 3 deletions
15
module/core/derive_tools/tests/inc/deref_mut/struct_tuple.rs
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 |
---|---|---|
@@ -1,8 +1,17 @@ | ||
use core::ops::{ Deref }; | ||
use derive_tools::{ Deref, DerefMut }; | ||
use core::ops::Deref; | ||
use derive_tools::DerefMut; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive ( Deref, DerefMut ) ] | ||
#[ derive ( DerefMut ) ] | ||
struct StructTuple( String, i32 ); | ||
|
||
impl Deref for StructTuple | ||
{ | ||
type Target = String; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&self.0 | ||
} | ||
} | ||
|
||
include!( "./only_test/struct_tuple.rs" ); |
Oops, something went wrong.