Logo

Programming-Idioms

History of Idiom 256 > diff from v31 to v32

Edit summary for version 32 by programming-idioms.org:
[Rust] Added Doc URL for rev

Version 31

2022-12-11, 21:23:23

Version 32

2022-12-15, 09:14:09

Idiom #256 Count backwards

Print the numbers 5, 4, ..., 0 (included), one line per number.

Idiom #256 Count backwards

Print the numbers 5, 4, ..., 0 (included), one line per number.

Extra Keywords
countdown negative step reverse
Extra Keywords
countdown negative step reverse
Code
(0..=5).rev().for_each(|i| println!("{}", i));
Code
(0..=5).rev().for_each(|i| println!("{}", i));
Comments bubble
Use _(0..=5).rev()_.
(5..=0) will not do anything.
Comments bubble
Use _(0..=5).rev()_.
(5..=0) will not do anything.
Doc URL
https://doc.rust-lang.org/std/iter/struct.Rev.html
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=aa66e40dc5fc89322c1a89d3d473fbe3
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=aa66e40dc5fc89322c1a89d3d473fbe3