maghoff / bart

A compile time templating language for Rust inspired by Mustache
https://crates.io/crates/bart
MIT License
37 stars 7 forks source link

Fix iteration of slices #7

Closed maghoff closed 7 years ago

maghoff commented 7 years ago

I'd like to be able to iterate over slices, such as &'a [i32]. Right now, it is possible to iterate over Vec<i32>, but not a slice.

For the template {{#list}}{{.}}{{/list}}, the generated code is something like:

for _s1 in &self.list { ... }

If I remove the &, iterating over slices starts to work, but iterating over Vecs stops working.

Perhaps this can be solved generically by way of some AsRef or Borrow shenannigans?