Skip to content

Commit

Permalink
Better documentation and iteration interface for value (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Oct 23, 2022
1 parent 491ce5e commit 34870b6
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 90 deletions.
4 changes: 2 additions & 2 deletions minijinja/src/filters.rs
Expand Up @@ -636,7 +636,7 @@ mod builtins {
if count == 0 {
return Err(Error::new(ErrorKind::InvalidOperation, "count cannot be 0"));
}
let items = ok!(value.try_iter()).collect::<Vec<_>>();
let items = ok!(value.try_iter_owned()).collect::<Vec<_>>();
let len = items.len();
let items_per_slice = len / count;
let slices_with_extra = len % count;
Expand Down Expand Up @@ -688,7 +688,7 @@ mod builtins {
let mut rv = Vec::new();
let mut tmp = Vec::with_capacity(count);

for item in ok!(value.try_iter()) {
for item in ok!(value.try_iter_owned()) {
if tmp.len() == count {
rv.push(Value::from(mem::replace(
&mut tmp,
Expand Down
2 changes: 1 addition & 1 deletion minijinja/src/key/mod.rs
Expand Up @@ -269,7 +269,7 @@ pub mod key_interning {

let v = Value::from_serializable(&vec![m.clone(), m.clone(), m.clone()]);

for value in v.try_iter().unwrap() {
for value in v.try_iter_owned().unwrap() {
match value.0 {
ValueRepr::Map(m, _) => {
let k = m.iter().next().unwrap().0;
Expand Down

0 comments on commit 34870b6

Please sign in to comment.