Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{ for<N> ... } bounded lists #100

Merged
merged 9 commits into from
Apr 11, 2024
Merged

{ for<N> ... } bounded lists #100

merged 9 commits into from
Apr 11, 2024

Conversation

maciejhirsz
Copy link
Owner

This PR adds a new way to declare lists by adding <N> after the for keyword:

view! {
    <ol.unbounded>
    {
       // Still works as it used to!
       for (0..10).map(|n| view! { <li>{n} })
    }
    </ol>

    <ol.bounded>
    {
       // A list that's bound to max length of 10
       for<10> (0..10).map(|n| view! { <li>{n} })
    }
    </ol>
}

Unlike the default unbounded lists, bounded lists are array-backed and therefore do not cause any allocations.

@maciejhirsz maciejhirsz merged commit 3e2121c into master Apr 11, 2024
4 checks passed
@maciejhirsz maciejhirsz deleted the bounded-list branch April 11, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant