-
Notifications
You must be signed in to change notification settings - Fork 37
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 #1305 from YBoy-git/derive_deref
READY : (derive_tools) : derive_deref & derive_deref_mut implementation improvement & tests extension & From docs
- Loading branch information
Showing
107 changed files
with
2,696 additions
and
92 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
module/core/derive_tools/tests/inc/deref/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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use core::fmt::Debug; | ||
|
||
use core::ops::Deref; | ||
use derive_tools::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref ) ] | ||
struct BoundsInlined< T : ToString, U : Debug >( T, U ); | ||
|
||
include!( "./only_tests/bounds_inlined.rs" ); |
17 changes: 17 additions & 0 deletions
17
module/core/derive_tools/tests/inc/deref/bounds_inlined_manual.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use core::fmt::Debug; | ||
|
||
use core::ops::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
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_tests/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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use core::fmt::Debug; | ||
|
||
use core::ops::Deref; | ||
use derive_tools::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref ) ] | ||
struct BoundsMixed< T : ToString, U >( T, U ) | ||
where | ||
U : Debug; | ||
|
||
include!( "./only_tests/bounds_mixed.rs" ); |
21 changes: 21 additions & 0 deletions
21
module/core/derive_tools/tests/inc/deref/bounds_mixed_manual.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use core::fmt::Debug; | ||
|
||
use core::ops::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
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_tests/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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
trait Trait<'a> {} | ||
impl<'a> Trait<'a> for i32 {} | ||
|
||
use core::ops::Deref; | ||
use derive_tools::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref ) ] | ||
struct BoundsWhere< T, U >( T, U ) | ||
where | ||
T : ToString, | ||
for< 'a > U : Trait< 'a >; | ||
|
||
include!( "./only_tests/bounds_where.rs" ); |
24 changes: 24 additions & 0 deletions
24
module/core/derive_tools/tests/inc/deref/bounds_where_manual.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
trait Trait<'a> {} | ||
impl<'a> Trait<'a> for i32 {} | ||
|
||
use core::ops::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
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_tests/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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use core::ops::Deref; | ||
use derive_tools::Deref; | ||
|
||
#[ allow( dead_code) ] | ||
#[ derive( Deref ) ] | ||
enum EnumNamed | ||
{ | ||
A { a : String, b : i32 }, | ||
B { a : String, b : i32 }, | ||
} | ||
|
||
include!( "./only_tests/enum_named.rs" ); |
12 changes: 12 additions & 0 deletions
12
module/core/derive_tools/tests/inc/deref/enum_named_empty.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use core::ops::Deref; | ||
use derive_tools::Deref; | ||
|
||
#[ allow( dead_code) ] | ||
#[ derive( Deref ) ] | ||
enum EnumNamedEmpty | ||
{ | ||
A {}, | ||
B {}, | ||
} | ||
|
||
include!( "./only_tests/enum_named_empty.rs" ); |
19 changes: 19 additions & 0 deletions
19
module/core/derive_tools/tests/inc/deref/enum_named_empty_manual.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use core::ops::Deref; | ||
|
||
#[ allow( dead_code) ] | ||
enum EnumNamedEmpty | ||
{ | ||
A {}, | ||
B {}, | ||
} | ||
|
||
impl Deref for EnumNamedEmpty | ||
{ | ||
type Target = (); | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&() | ||
} | ||
} | ||
|
||
include!( "./only_tests/enum_named_empty.rs" ); |
22 changes: 22 additions & 0 deletions
22
module/core/derive_tools/tests/inc/deref/enum_named_manual.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use core::ops::Deref; | ||
|
||
#[ allow( dead_code) ] | ||
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_tests/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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use core::ops::Deref; | ||
use derive_tools::Deref; | ||
|
||
#[ allow( dead_code) ] | ||
#[ derive( Deref ) ] | ||
enum EnumTuple | ||
{ | ||
A( String, i32 ), | ||
B( String, i32 ), | ||
} | ||
|
||
include!( "./only_tests/enum_tuple.rs" ); |
12 changes: 12 additions & 0 deletions
12
module/core/derive_tools/tests/inc/deref/enum_tuple_empty.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use core::ops::Deref; | ||
use derive_tools::Deref; | ||
|
||
#[ allow( dead_code) ] | ||
#[ derive( Deref ) ] | ||
enum EnumTupleEmpty | ||
{ | ||
A(), | ||
B(), | ||
} | ||
|
||
include!( "./only_tests/enum_tuple_empty.rs" ); |
19 changes: 19 additions & 0 deletions
19
module/core/derive_tools/tests/inc/deref/enum_tuple_empty_manual.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use core::ops::Deref; | ||
|
||
#[ allow( dead_code) ] | ||
enum EnumTupleEmpty | ||
{ | ||
A(), | ||
B(), | ||
} | ||
|
||
impl Deref for EnumTupleEmpty | ||
{ | ||
type Target = (); | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&() | ||
} | ||
} | ||
|
||
include!( "./only_tests/enum_tuple_empty.rs" ); |
22 changes: 22 additions & 0 deletions
22
module/core/derive_tools/tests/inc/deref/enum_tuple_manual.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use core::ops::Deref; | ||
|
||
#[ allow( dead_code) ] | ||
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_tests/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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use core::ops::Deref; | ||
use derive_tools::Deref; | ||
|
||
#[ allow( dead_code) ] | ||
#[ derive( Deref ) ] | ||
enum EnumUnit | ||
{ | ||
A, | ||
B, | ||
} | ||
|
||
include!( "./only_tests/enum_unit.rs" ); |
19 changes: 19 additions & 0 deletions
19
module/core/derive_tools/tests/inc/deref/enum_unit_manual.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use core::ops::Deref; | ||
|
||
#[ allow( dead_code) ] | ||
enum EnumUnit | ||
{ | ||
A, | ||
B, | ||
} | ||
|
||
impl Deref for EnumUnit | ||
{ | ||
type Target = (); | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&() | ||
} | ||
} | ||
|
||
include!( "./only_tests/enum_unit.rs" ); |
8 changes: 8 additions & 0 deletions
8
module/core/derive_tools/tests/inc/deref/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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use core::ops::Deref; | ||
use derive_tools::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref ) ] | ||
struct GenericsConstants< const N : usize >( i32 ); | ||
|
||
include!( "./only_tests/generics_constants.rs" ); |
8 changes: 8 additions & 0 deletions
8
module/core/derive_tools/tests/inc/deref/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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use core::ops::Deref; | ||
use derive_tools::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref ) ] | ||
struct GenericsConstantsDefault< const N : usize = 0 >( i32 ); | ||
|
||
include!( "./only_tests/generics_constants_default.rs" ); |
15 changes: 15 additions & 0 deletions
15
module/core/derive_tools/tests/inc/deref/generics_constants_default_manual.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use core::ops::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
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_tests/generics_constants_default.rs" ); |
15 changes: 15 additions & 0 deletions
15
module/core/derive_tools/tests/inc/deref/generics_constants_manual.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use core::ops::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
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_tests/generics_constants.rs" ); |
8 changes: 8 additions & 0 deletions
8
module/core/derive_tools/tests/inc/deref/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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use core::ops::Deref; | ||
use derive_tools::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref ) ] | ||
struct GenericsLifetimes< 'a >( &'a i32 ); | ||
|
||
include!( "./only_tests/generics_lifetimes.rs" ); |
15 changes: 15 additions & 0 deletions
15
module/core/derive_tools/tests/inc/deref/generics_lifetimes_manual.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use core::ops::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
struct GenericsLifetimes< 'a >( &'a i32 ); | ||
|
||
impl< 'a > Deref for GenericsLifetimes< 'a > | ||
{ | ||
type Target = &'a i32; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&self.0 | ||
} | ||
} | ||
|
||
include!( "./only_tests/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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use core::ops::Deref; | ||
use derive_tools::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( Deref ) ] | ||
struct GenericsTypes< T >( T ); | ||
|
||
include!( "./only_tests/generics_types.rs" ); |
8 changes: 8 additions & 0 deletions
8
module/core/derive_tools/tests/inc/deref/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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use core::ops::Deref; | ||
use derive_tools::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive ( Deref ) ] | ||
struct GenericsTypesDefault< T = i32 >( T ); | ||
|
||
include!( "./only_tests/generics_types_default.rs" ); |
15 changes: 15 additions & 0 deletions
15
module/core/derive_tools/tests/inc/deref/generics_types_default_manual.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use core::ops::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
struct GenericsTypesDefault< T = i32 >( T ); | ||
|
||
impl< T > Deref for GenericsTypesDefault< T > | ||
{ | ||
type Target = T; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&self.0 | ||
} | ||
} | ||
|
||
include!( "./only_tests/generics_types_default.rs" ); |
15 changes: 15 additions & 0 deletions
15
module/core/derive_tools/tests/inc/deref/generics_types_manual.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use core::ops::Deref; | ||
|
||
#[ allow( dead_code ) ] | ||
struct GenericsTypes< T >( T ); | ||
|
||
impl< T > Deref for GenericsTypes< T > | ||
{ | ||
type Target = T; | ||
fn deref( &self ) -> &Self::Target | ||
{ | ||
&self.0 | ||
} | ||
} | ||
|
||
include!( "./only_tests/generics_types.rs" ); |
Oops, something went wrong.