-
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.
* fut: basic struct tests * fut: named struct draft impl * fut: wnamed struct Generics realization * fix: formatting fix * fut: enum and struct macros implementation * refactor: #[ index ] attribute implementation and general macros, tests refactor * ref: basic implementation * ref: comments fix * fut: struct implementation * fut: add try_build tests, ref: delete not used attrs * ref: formatting * fix: formatting and added attributes
- Loading branch information
Showing
30 changed files
with
736 additions
and
3 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
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
13 changes: 13 additions & 0 deletions
13
module/core/derive_tools/tests/inc/index/compiletime/enum.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,13 @@ | ||
use derive_tools::Index; | ||
|
||
#[ derive( Index ) ] | ||
enum Enum< T > | ||
{ | ||
Nothing, | ||
#[ index ] | ||
IndexVector( Vec< T > ) | ||
} | ||
|
||
fn main() | ||
{ | ||
} |
7 changes: 7 additions & 0 deletions
7
module/core/derive_tools/tests/inc/index/compiletime/enum.stderr
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 @@ | ||
error: proc-macro derive panicked | ||
--> tests/inc/index/compiletime/enum.rs:3:12 | ||
| | ||
3 | #[ derive( Index ) ] | ||
| ^^^^^ | ||
| | ||
= help: message: not implemented: Index not implemented for Enum |
14 changes: 14 additions & 0 deletions
14
module/core/derive_tools/tests/inc/index/compiletime/struct.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 @@ | ||
use derive_tools::Index; | ||
|
||
#[ derive( Index ) ] | ||
struct StructMultipleNamed< T > | ||
{ | ||
#[ index ] | ||
a: Vec< T >, | ||
#[ index ] | ||
b : Vec< T >, | ||
} | ||
|
||
fn main() | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
module/core/derive_tools/tests/inc/index/compiletime/struct.stderr
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 @@ | ||
error: Only one field can include #[index] derive macro | ||
--> tests/inc/index/compiletime/struct.rs:6:3 | ||
| | ||
6 | / #[ index ] | ||
7 | | a: Vec< T >, | ||
8 | | #[ index ] | ||
9 | | b : Vec< T >, | ||
| |_______________^ |
10 changes: 10 additions & 0 deletions
10
module/core/derive_tools/tests/inc/index/compiletime/struct_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,10 @@ | ||
use derive_tools::Index; | ||
|
||
#[ derive( Index ) ] | ||
struct EmptyStruct | ||
{ | ||
} | ||
|
||
fn main() | ||
{ | ||
} |
7 changes: 7 additions & 0 deletions
7
module/core/derive_tools/tests/inc/index/compiletime/struct_named_empty.stderr
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 @@ | ||
error: proc-macro derive panicked | ||
--> tests/inc/index/compiletime/struct_named_empty.rs:3:12 | ||
| | ||
3 | #[ derive( Index ) ] | ||
| ^^^^^ | ||
| | ||
= help: message: not implemented: Index not implemented for Unit |
9 changes: 9 additions & 0 deletions
9
module/core/derive_tools/tests/inc/index/compiletime/struct_unit.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,9 @@ | ||
use derive_tools::Index; | ||
|
||
#[ derive( Index ) ] | ||
struct StructUnit; | ||
|
||
fn main() | ||
{ | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
module/core/derive_tools/tests/inc/index/compiletime/struct_unit.stderr
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 @@ | ||
error: proc-macro derive panicked | ||
--> tests/inc/index/compiletime/struct_unit.rs:3:12 | ||
| | ||
3 | #[ derive( Index ) ] | ||
| ^^^^^ | ||
| | ||
= help: message: not implemented: Index not implemented for Unit |
14 changes: 14 additions & 0 deletions
14
module/core/derive_tools/tests/inc/index/only_test/struct_multiple_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,14 @@ | ||
#[ test ] | ||
fn index() | ||
{ | ||
let x = StructMultipleNamed | ||
{ | ||
a: vec![ 12, 22 ], | ||
b: vec![ 33, 55 ] | ||
}; | ||
let v = vec![ 33, 55 ]; | ||
let exp = ( v[ 0 ], v[ 1 ] ); | ||
let got = ( x[ 0 ], x[ 1 ] ); | ||
|
||
assert_eq!( got, exp ); | ||
} |
8 changes: 8 additions & 0 deletions
8
module/core/derive_tools/tests/inc/index/only_test/struct_multiple_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,8 @@ | ||
#[ test ] | ||
fn index() | ||
{ | ||
let x = StructMultipleTuple( false, vec![ 2, 44, 81 ] ); | ||
let exp = ( 2, 44 ); | ||
let got = ( x[ 0 ], x[ 1 ] ); | ||
assert_eq!( got, exp ); | ||
} |
13 changes: 13 additions & 0 deletions
13
module/core/derive_tools/tests/inc/index/only_test/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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#[ test ] | ||
fn index() | ||
{ | ||
let x = StructNamed | ||
{ | ||
a: vec![ false, true ] | ||
}; | ||
let v = vec![ false, true ]; | ||
let exp = ( v[ 0 ], v[ 1 ] ); | ||
let got = ( x[ 0 ], x[ 1 ] ); | ||
|
||
assert_eq!( got, exp ); | ||
} |
9 changes: 9 additions & 0 deletions
9
module/core/derive_tools/tests/inc/index/only_test/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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#[ test ] | ||
fn index() | ||
{ | ||
let x = StructTuple( vec![ 2, 44, 81 ] ); | ||
let exp = ( 2, 44 ); | ||
let got = ( x[ 0 ], x[ 1 ] ); | ||
|
||
assert_eq!( got, exp ); | ||
} |
13 changes: 13 additions & 0 deletions
13
module/core/derive_tools/tests/inc/index/struct_multiple_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,13 @@ | ||
#![ allow( dead_code ) ] | ||
#[ allow( unused_imports ) ] | ||
use super::*; | ||
|
||
#[ derive( the_module::Index ) ] | ||
struct StructMultipleNamed< T > | ||
{ | ||
a : Vec< T >, | ||
#[ index ] | ||
b : Vec< T >, | ||
} | ||
|
||
include!( "./only_test/struct_multiple_named.rs" ); |
20 changes: 20 additions & 0 deletions
20
module/core/derive_tools/tests/inc/index/struct_multiple_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,20 @@ | ||
use core::ops::Index; | ||
|
||
#[ allow( dead_code ) ] | ||
struct StructMultipleNamed< T > | ||
{ | ||
a: Vec< T >, | ||
b: Vec< T >, | ||
} | ||
|
||
impl< T > Index< usize > for StructMultipleNamed< T > | ||
{ | ||
type Output = T; | ||
|
||
fn index( &self, index : usize ) -> &Self::Output | ||
{ | ||
&self.b[ index ] | ||
} | ||
} | ||
|
||
include!( "./only_test/struct_multiple_named.rs" ); |
13 changes: 13 additions & 0 deletions
13
module/core/derive_tools/tests/inc/index/struct_multiple_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,13 @@ | ||
#![ allow( dead_code ) ] | ||
#[ allow( unused_imports ) ] | ||
use super::*; | ||
|
||
#[ derive( the_module::Index ) ] | ||
struct StructMultipleTuple< T > | ||
( | ||
bool, | ||
#[ index ] | ||
Vec< T >, | ||
); | ||
|
||
include!( "./only_test/struct_multiple_tuple.rs" ); |
16 changes: 16 additions & 0 deletions
16
module/core/derive_tools/tests/inc/index/struct_multiple_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,16 @@ | ||
use core::ops::Index; | ||
|
||
#[ allow( dead_code) ] | ||
struct StructMultipleTuple< T >( bool, Vec< T > ); | ||
|
||
impl< T > Index< usize > for StructMultipleTuple< T > | ||
{ | ||
type Output = T; | ||
|
||
fn index( &self, index : usize ) -> &Self::Output | ||
{ | ||
&self.1[ index ] | ||
} | ||
} | ||
|
||
include!( "./only_test/struct_multiple_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 @@ | ||
#![ allow( dead_code ) ] | ||
#[ allow( unused_imports ) ] | ||
use super::*; | ||
|
||
#[ derive( the_module::Index ) ] | ||
struct StructNamed< T > | ||
{ | ||
#[ index ] | ||
a : Vec< T >, | ||
} | ||
|
||
include!( "./only_test/struct_named.rs" ); |
19 changes: 19 additions & 0 deletions
19
module/core/derive_tools/tests/inc/index/struct_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,19 @@ | ||
use core::ops::Index; | ||
|
||
#[ allow( dead_code ) ] | ||
struct StructNamed< T > | ||
{ | ||
a: Vec< T > | ||
} | ||
|
||
impl< T > Index< usize > for StructNamed< T > | ||
{ | ||
type Output = T; | ||
|
||
fn index( &self, index : usize ) -> &Self::Output | ||
{ | ||
&self.a[ index ] | ||
} | ||
} | ||
|
||
include!( "./only_test/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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use super::*; | ||
|
||
#[ allow( dead_code ) ] | ||
#[ derive( the_module::Index ) ] | ||
struct StructTuple< T > | ||
( | ||
#[ index ] | ||
Vec< T > | ||
); | ||
|
||
include!( "./only_test/struct_tuple.rs" ); |
16 changes: 16 additions & 0 deletions
16
module/core/derive_tools/tests/inc/index/struct_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,16 @@ | ||
use core::ops::Index; | ||
|
||
#[ allow( dead_code) ] | ||
struct StructTuple< T >( Vec< T > ); | ||
|
||
impl< T > Index< usize > for StructTuple< T > | ||
{ | ||
type Output = T; | ||
|
||
fn index( &self, index : usize ) -> &Self::Output | ||
{ | ||
&self.0[ index ] | ||
} | ||
} | ||
|
||
include!( "./only_test/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
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
Oops, something went wrong.