Generate lower case ASCII alphabet: Difference between revisions

Content added Content deleted
(Use `b'a'` instead of `'a' as u8`, put .map on a new line to shorten line length and replace _ with `char`)
Line 1,371: Line 1,371:


=={{header|Rust}}==
=={{header|Rust}}==
<lang rust>
<lang rust>fn main() {
fn main() {
// An iterator over the lowercase alpha's
// An iterator over the lowercase alpha's
let ascii_iter = (0..26).map(|x| (x + 'a' as u8) as char);
let ascii_iter = (0..26)
.map(|x| (x + b'a') as char);

println!("{:?}", ascii_iter.collect::<Vec<_>>());
println!("{:?}", ascii_iter.collect::<Vec<char>>());
}
</lang>
}</lang>
{{out}}
{{out}}
<pre>
<pre>
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
</pre>
</pre>



=={{header|S-lang}}==
=={{header|S-lang}}==