From ba4e9199da7aba30b29ac53c3b2ab6721f6ae7e6 Mon Sep 17 00:00:00 2001 From: Ridgep <ridpet-5@student.ltu.se> Date: Thu, 7 Mar 2019 17:00:11 +0100 Subject: [PATCH] bare3_2 --- examples/bare3.rs | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/examples/bare3.rs b/examples/bare3.rs index a52a2f5..3d2a21d 100644 --- a/examples/bare3.rs +++ b/examples/bare3.rs @@ -18,8 +18,11 @@ use cortex_m_semihosting::{hprint, hprintln}; #[entry] fn main() -> ! { hprintln!("bare3").unwrap(); - let s = "ABCD"; - let bs = s.as_bytes(); + let s: &str = "ABCD"; + let bs: &[u8] = s.as_bytes(); + let c: &u8; + let i: i32; + let a: [u8; 4]; hprintln!("s = {}", s).unwrap(); hprintln!("bs = {:?}", bs).unwrap(); @@ -36,7 +39,7 @@ fn main() -> ! { hprintln!("").unwrap(); - let a = [65u8; 4]; + a = [65u8; 4]; //let mut a = [0u8; 4]; hprintln!("").unwrap(); @@ -52,27 +55,38 @@ fn main() -> ! { // // 1. What is the output in the `openocd` (Adapter Output) console? // -// ** your answer here ** +// bare3 +// s = ABCD +// bs = [65, 66, 67, 68] +// iterate over slice +// 65,66,67,68,iterate iterate using (raw) indexing +// 65, +// 66, +// 67, +// 68, +// +// +// a = AAAA // // What is the type of `s`? // -// ** your answer here ** +// type string // // What is the type of `bs`? // -// ** your answer here ** +// u8 byte array // // What is the type of `c`? // -// ** your answer here ** +// Pointer for an u8 element in the bs array. // // What is the type of `a`? // -// ** your answer here ** +// it's an array of u8 // // What is the type of `i`? // -// ** your answer here ** +// a int variable, i32 // // Commit your answers (bare3_1) // -- GitLab