fn main() { let z = 15; let z = z + 1; // Shadowing: z is now 16 let z = z * 2; // Shadowing again: z is now 32 println!("The final value of z is: {}", z); // Output: 32 }
Write, Run & Share Rust code online using OneCompiler's Rust online compiler for free. It's one of the robust, feature-rich online compilers for Rust language. Getting started with the OneCompiler's Rust editor is easy and fast. The editor shows sample boilerplate code when you choose language as Rust and start coding.