File tree 3 files changed +34
-1
lines changed
3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " typle"
3
- version = " 0.9.12 "
3
+ version = " 0.9.13 "
4
4
edition = " 2021"
5
5
description = " Generic tuple bounds and transformations"
6
6
license = " MIT"
Original file line number Diff line number Diff line change @@ -682,6 +682,11 @@ pub fn typle_any(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
682
682
/// None::<(i32, &str)>
683
683
/// );
684
684
/// ```
685
+ ///
686
+ /// The `typle_fold!` macro can also be used for recursive types. See the
687
+ /// [example in the tests].
688
+ ///
689
+ /// [example in the tests]: https://github.com/jongiddy/typle/blob/main/tests/compile/typle_fold.rs
685
690
#[ proc_macro]
686
691
pub fn typle_fold ( item : proc_macro:: TokenStream ) -> proc_macro:: TokenStream {
687
692
Error :: new_spanned (
Original file line number Diff line number Diff line change
1
+ use typle:: typle;
2
+
3
+ pub struct Something { }
4
+
5
+ pub trait IsUseful < Other > {
6
+ type State : IsUseful < Something > ;
7
+ }
8
+
9
+ pub trait UsefulTrait {
10
+ type UsefulType : IsUseful < Something > ;
11
+ }
12
+
13
+ #[ typle( Tuple for 1 ..=3 ) ]
14
+ impl < T : Tuple > UsefulTrait for T
15
+ where
16
+ T < _ > : UsefulTrait ,
17
+ typle_bound!( i in 1 ..T :: LEN => T < { i} > :: UsefulType ) : IsUseful <
18
+ typle_fold ! (
19
+ T0 :: UsefulType ;
20
+ j in 1 ..i => |Inner | <T <{ j} >:: UsefulType as IsUseful <Inner >>:: State
21
+ ) ,
22
+ > ,
23
+ {
24
+ type UsefulType = typle_fold ! (
25
+ T0 :: UsefulType ;
26
+ j in 1 ..T :: LEN => |Inner | <T <{ j} >:: UsefulType as IsUseful <Inner >>:: State
27
+ ) ;
28
+ }
You can’t perform that action at this time.
0 commit comments