Skip to content

Commit

Permalink
Releae 0.9.13
Browse files Browse the repository at this point in the history
  • Loading branch information
jongiddy committed Apr 14, 2024
1 parent 7855e1e commit 5b00600
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "typle"
version = "0.9.12"
version = "0.9.13"
edition = "2021"
description = "Generic tuple bounds and transformations"
license = "MIT"
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,11 @@ pub fn typle_any(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
/// None::<(i32, &str)>
/// );
/// ```
///
/// The `typle_fold!` macro can also be used for recursive types. See the
/// [example in the tests].
///
/// [example in the tests]: https://github.com/jongiddy/typle/blob/main/tests/compile/typle_fold.rs
#[proc_macro]
pub fn typle_fold(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
Error::new_spanned(
Expand Down
28 changes: 28 additions & 0 deletions tests/compile/typle_fold.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use typle::typle;

pub struct Something {}

pub trait IsUseful<Other> {
type State: IsUseful<Something>;
}

pub trait UsefulTrait {
type UsefulType: IsUseful<Something>;
}

#[typle(Tuple for 1..=3)]
impl<T: Tuple> UsefulTrait for T
where
T<_>: UsefulTrait,
typle_bound!(i in 1..T::LEN => T<{i}>::UsefulType):IsUseful<
typle_fold!(
T0::UsefulType;
j in 1..i => |Inner| <T<{j}>::UsefulType as IsUseful<Inner>>::State
),
>,
{
type UsefulType = typle_fold!(
T0::UsefulType;
j in 1..T::LEN => |Inner| <T<{j}>::UsefulType as IsUseful<Inner>>::State
);
}

0 comments on commit 5b00600

Please sign in to comment.