News for hackers. Stuff that matters.
Re:Show HN: A Graphviz Implementation in Rust by jll29 on Thursday March 17, 2022 @06:09PM (#30716399)
This does not seem to compile:

  --> src/core/color.rs:180:21
      |
  180 |         for pair in KNOWN_COLORS {
      |                     ^^^^^^^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it
      |
      = help: the trait `Iterator` is not implemented for `[(&str, u32); 148]`
  ...
  error[E0277]: `[geometry::Point; 20]` is not an iterator
  --> src/topo/placer/edge_fixer.rs:272:39
      |
  272 |                         for offset in offsets {
      |                                       ^^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it
Do I need a specific version of Rust, perhaps?
Re:Show HN: A Graphviz Implementation in Rust by kevincox on Thursday March 17, 2022 @06:11PM (#30716421)
It sounds like your rust is too old. IIRC the array FromIterator is only a month or two old.
Re:Show HN: A Graphviz Implementation in Rust by tialaramex on Thursday March 17, 2022 @07:50PM (#30717146)
Rust 1.53 is from June 2021 and that's where this first works (until Rust Edition 2021 you can't actually just method call into_iter() on arrays because that would mask syntax that could work in some cases on older Rust code, but this code uses the for loop which does not actually do a method call to get the iterator)
Re:Show HN: A Graphviz Implementation in Rust by jll29 on Thursday March 17, 2022 @07:56PM (#30717184)
Thanks, Kevin, that was it. I didn't expect Rust to (still) move that fast. ;)
Re:Show HN: A Graphviz Implementation in Rust by tialaramex on Thursday March 17, 2022 @10:46PM (#30718256)
This (arrays implementing IntoIterator) is probably the improvement with broadest impact of the last 12 months.

It even makes lots of Rust's documentation examples more readable. Previously if there's an iterator involved somewhere, the doc example ends up constructing say vec![1,2,3,4,5] and a reasonable novice might ask why do we use a vector here? Today Rust's documentation just says [1,2,3,4,5] because sure, an array of five elements 1, 2, 3, 4, 5 that makes sense why use any other data structure?