Skip to content

Commit ef12b4d

Browse files
committed
Simplify typle_all! and typle_any! docs
1 parent 5684311 commit ef12b4d

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/lib.rs

+16-14
Original file line numberDiff line numberDiff line change
@@ -551,14 +551,15 @@ impl TryFrom<TokenStream> for TypleMacro {
551551
/// ```rust
552552
/// # use typle::typle;
553553
/// #[typle(Tuple for 0..=12)]
554-
/// fn check<T: Tuple<&str>>(t: T) -> [bool; 2] {
555-
/// [
556-
/// typle_all!(i in ..T::LEN => t[[i]].len() > 5),
557-
/// typle_any!(i in ..T::LEN => t[[i]].len() > 5),
558-
/// ]
554+
/// fn all_long<T: Tuple<&str>>(t: T) -> bool {
555+
/// typle_all!(i in ..T::LEN => t[[i]].len() > 5)
559556
/// }
560-
/// assert_eq!(check(("the", "longest", "word")), [false, true]);
561-
/// assert_eq!(check(()), [true, false]);
557+
/// // Return `true` if all words meet the criteria.
558+
/// assert_eq!(all_long(("longest", "phrase")), true);
559+
/// // Return `false` if any words fail to meet the criteria.
560+
/// assert_eq!(all_long(("the", "longest", "word")), false);
561+
/// // Return `true` for an empty tuple as no words fail to meet the criteria.
562+
/// assert_eq!(all_long(()), true);
562563
/// ```
563564
///
564565
#[proc_macro]
@@ -576,14 +577,15 @@ pub fn typle_all(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
576577
/// ```rust
577578
/// # use typle::typle;
578579
/// #[typle(Tuple for 0..=12)]
579-
/// fn check<T: Tuple<&str>>(t: T) -> [bool; 2] {
580-
/// [
581-
/// typle_all!(i in ..T::LEN => t[[i]].len() > 5),
582-
/// typle_any!(i in ..T::LEN => t[[i]].len() > 5),
583-
/// ]
580+
/// fn any_long<T: Tuple<&str>>(t: T) -> bool {
581+
/// typle_any!(i in ..T::LEN => t[[i]].len() > 5)
584582
/// }
585-
/// assert_eq!(check(("the", "longest", "word")), [false, true]);
586-
/// assert_eq!(check(()), [true, false]);
583+
/// // Return `true` if any word meets the criteria.
584+
/// assert_eq!(any_long(("the", "longest", "word")), true);
585+
/// // Return `false` if no words meet the criteria.
586+
/// assert_eq!(any_long(("short", "words")), false);
587+
/// // Return `false` for an empty tuple as no words meet the criteria.
588+
/// assert_eq!(any_long(()), false);
587589
/// ```
588590
///
589591
#[proc_macro]

0 commit comments

Comments
 (0)