I am learning rust and I always try some basic codes while learning any language. When I learned the syntax for loops in Rust, I tried to write a code for a half pyramid pattern like I always do. But it dosen't seem to be working. Cam someone please teach me how to?
This is the code that I wrote:
#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(unused_mut)]
fn main()
{
let mut x: isize;
let mut y: isize;
y = 5;
for x in 0..=y
{
for _ in 0..=x
{
println!("*");
}
println!();
}
}
I am expecting an output:
*
**
***
****
*****
But what I am getting is:
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*