Skip to content

Commit 5b00600

Browse files
committed
Releae 0.9.13
1 parent 7855e1e commit 5b00600

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "typle"
3-
version = "0.9.12"
3+
version = "0.9.13"
44
edition = "2021"
55
description = "Generic tuple bounds and transformations"
66
license = "MIT"

src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,11 @@ pub fn typle_any(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
682682
/// None::<(i32, &str)>
683683
/// );
684684
/// ```
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
685690
#[proc_macro]
686691
pub fn typle_fold(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
687692
Error::new_spanned(

tests/compile/typle_fold.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
}

0 commit comments

Comments
 (0)