Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Tips and Traps

  1. Range does has the map method.

  2. When constructing a range using m..n, an empty range is yield if m≥nm \ge n. If you need a decreasing range, first construst an increasing range and then call the reverse method on it.

  3. Module std::collections has a good summary on when to each which collection in Rust.

0..5
0
1
2
3
4
()
0
1
2
3
4
()
0
2
4
()
4
3
2
1
0
()
4
2
0
()
[2, 3, 4, 5, 6, 7, 8, 9, 10]
[3, 6, 9]
Some(3)
3
4
Some(9)
(1..10).iter().sum()
        ^^^^ method not found in `std::ops::Range<{integer}>`
no method named `iter` found for struct `std::ops::Range<{integer}>` in the current scope
[1, 2, 3]
6
6
1.0
1.0