Skip to content
Snippets Groups Projects
Commit a857e888 authored by August Svensson's avatar August Svensson
Browse files

bare3_2

parent 23d51624
Branches
No related tags found
No related merge requests found
...@@ -18,25 +18,28 @@ use cortex_m_semihosting::{hprint, hprintln}; ...@@ -18,25 +18,28 @@ use cortex_m_semihosting::{hprint, hprintln};
#[entry] #[entry]
fn main() -> ! { fn main() -> ! {
hprintln!("bare3").unwrap(); hprintln!("bare3").unwrap();
let s = "ABCD"; let s: &str = "ABCD";
let bs = s.as_bytes(); let bs: &[u8] = s.as_bytes();
hprintln!("s = {}", s).unwrap(); hprintln!("s = {}", s).unwrap();
hprintln!("bs = {:?}", bs).unwrap(); hprintln!("bs = {:?}", bs).unwrap();
hprintln!("iterate over slice").unwrap(); hprintln!("iterate over slice").unwrap();
for c in bs { for c in bs {
let c: &u8 = c;
hprint!("{},", c).unwrap(); hprint!("{},", c).unwrap();
} }
hprintln!("iterate iterate using (raw) indexing").unwrap(); hprintln!("iterate iterate using (raw) indexing").unwrap();
for i in 0..s.len() { for i in 0..s.len() {
let i: usize = i;
hprintln!("{},", bs[i]).unwrap(); hprintln!("{},", bs[i]).unwrap();
} }
hprintln!("").unwrap(); hprintln!("").unwrap();
let a = [65u8; 4]; let a: [u8; 4] = [65u8; 4];
//let mut a = [0u8; 4]; //let mut a = [0u8; 4];
hprintln!("").unwrap(); hprintln!("").unwrap();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment