Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Nested loops #7

@dtolnay

Description

@dtolnay

The _loop_indexes mechanism makes it seem like nested loops are intended to be supported, but I haven't figured it out. Here is what I tried:

{% for y in names %}
  {% for x in y %}
    x = {{ x }}
  {% endfor %}
{% endfor %}
#[derive(Template)]
#[template(path = "test")]
struct Test<'a> {
    names: Vec<Vec<&'a str>>,
}
error[E0277]: the trait bound `&&std::vec::Vec<&str>: std::iter::Iterator` is not satisfied
 --> src/main.rs:7:10
  |
7 | #[derive(Template)]
  |          ^^^^^^^^ the trait `std::iter::Iterator` is not implemented for `&&std::vec::Vec<&str>`
  |
  = note: `&&std::vec::Vec<&str>` is not an iterator; maybe try calling `.iter()` or a similar method
  = note: required by `std::iter::IntoIterator::into_iter`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions