Skip to content

Commit

Permalink
Use flex_unwrap() in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
L0g4n committed Feb 6, 2023
1 parent 3a0cc97 commit f7494a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion examples/console_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
extern crate lang_items;

use libtock_console::Console;
use libtock_drivers::result::FlexUnwrap;
#[cfg(not(feature = "std"))]
use libtock_runtime::{set_main, stack_size, TockSyscalls};
#[cfg(feature = "std")]
Expand All @@ -42,7 +43,9 @@ fn main() {
*byte = b'0' + ((i % 10) as u8);
}
buf[i] = b'\n';
Console::<Syscalls>::write(&buf[..(i + 1)]).ok().unwrap();
Console::<Syscalls>::write(&buf[..(i + 1)])
.map_err(|e| e.into())
.flex_unwrap();
}
}
}
7 changes: 4 additions & 3 deletions examples/erase_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern crate lang_items;
use core::fmt::Write;
use ctap2::env::tock::take_storage;
use libtock_console::Console;
use libtock_drivers::result::FlexUnwrap;
use libtock_leds::Leds;
use libtock_platform as platform;
#[cfg(not(feature = "std"))]
Expand Down Expand Up @@ -50,7 +51,7 @@ fn is_page_erased(storage: &dyn Storage, page: usize) -> bool {
}

fn main() {
Leds::<Syscalls>::on(1).unwrap(); // red on dongle
Leds::<Syscalls>::on(1).map_err(|e| e.into()).flex_unwrap(); // red on dongle
let mut storage = take_storage::<Syscalls, DefaultConfig>().unwrap();
let num_pages = storage.num_pages();
let mut console = Console::<Syscalls>::writer();
Expand All @@ -65,6 +66,6 @@ fn main() {
}
}
writeln!(console, "Done.").unwrap();
Leds::<Syscalls>::on(1).unwrap();
Leds::<Syscalls>::off(0).unwrap(); // green on dongle
Leds::<Syscalls>::on(1).map_err(|e| e.into()).flex_unwrap();
Leds::<Syscalls>::off(0).map_err(|e| e.into()).flex_unwrap(); // green on dongle
}

0 comments on commit f7494a2

Please sign in to comment.