From 8e1948cfb4dd91e40b74882240aa9ac3a0cb8caa Mon Sep 17 00:00:00 2001 From: Jonathan Cornaz Date: Sun, 3 Nov 2024 08:09:06 +0100 Subject: [PATCH] explain the benefit of using simple rust functions --- README.md | 8 ++++++++ src/lib.rs | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 7a08be6..6d22dd2 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,14 @@ let greeting = h1( assert_eq!(greeting.to_string(), r#"

Hello world!

"#); ``` +Because those are simple rust functions, it is easy to leverage rust features like conditions, loops and iterators: + +```rust +let list = ul([], (1..=3).map(|n| li([], [n.to_string().into()]))); +assert_eq!(list.to_string(), ""); +``` + + ## MSRV The minimum supported rust version is currently `1.60`. diff --git a/src/lib.rs b/src/lib.rs index acc7603..00238d5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,14 @@ //! assert_eq!(greeting.to_string(), r#"

Hello world!

"#); //! ``` //! +//! Because those are simple rust functions, it is easy to leverage rust features like conditions, loops and iterators: +//! +//! ``` +//! # use fun_html::{elt::{li,ul}}; +//! let list = ul([], (1..=3).map(|n| li([], [n.to_string().into()]))); +//! assert_eq!(list.to_string(), ""); +//! ``` +//! //! ## Escape hatches //! //! If necessary, it is possible to define custom elements and attributes with respectively [`Element::new`] and [`Attribute::new`].