From 6297f4f04679bb45fdcf0e55b64094c049dc70fa Mon Sep 17 00:00:00 2001 From: sheepwall <a.sve@live.se> Date: Fri, 8 Mar 2019 14:43:51 +0100 Subject: [PATCH] bare3_3 --- examples/bare3.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/bare3.rs b/examples/bare3.rs index caeba37..31e2475 100644 --- a/examples/bare3.rs +++ b/examples/bare3.rs @@ -40,7 +40,7 @@ fn main() -> ! { hprintln!("").unwrap(); let a: [u8; 4] = [65u8; 4]; - //let mut a = [0u8; 4]; + let mut a = [0u8; 4]; hprintln!("").unwrap(); hprintln!("a = {}", core::str::from_utf8(&a).unwrap()).unwrap(); @@ -98,7 +98,9 @@ fn main() -> ! { //` // Run the program, what happens and why? // -// ** your answer here ** +// ** Rust allows this shadowing and therefore builds without error. +// When the program runs, the last hprintln! prints "a =" without any characters. +// This is because a = [0, 0, 0, 0] and 0 in utf8 is the NULL character. ** // // Commit your answers (bare3_3) // -- GitLab