From f7494a283e22649f0b7e9be08915ba7dc1ab94aa Mon Sep 17 00:00:00 2001 From: L0g4n Date: Mon, 6 Feb 2023 22:32:47 +0100 Subject: [PATCH] Use flex_unwrap() in examples --- examples/console_test.rs | 5 ++++- examples/erase_storage.rs | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/console_test.rs b/examples/console_test.rs index a5d3da57..86ab50dc 100644 --- a/examples/console_test.rs +++ b/examples/console_test.rs @@ -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")] @@ -42,7 +43,9 @@ fn main() { *byte = b'0' + ((i % 10) as u8); } buf[i] = b'\n'; - Console::::write(&buf[..(i + 1)]).ok().unwrap(); + Console::::write(&buf[..(i + 1)]) + .map_err(|e| e.into()) + .flex_unwrap(); } } } diff --git a/examples/erase_storage.rs b/examples/erase_storage.rs index 9bc3e0c0..269ddd5d 100644 --- a/examples/erase_storage.rs +++ b/examples/erase_storage.rs @@ -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"))] @@ -50,7 +51,7 @@ fn is_page_erased(storage: &dyn Storage, page: usize) -> bool { } fn main() { - Leds::::on(1).unwrap(); // red on dongle + Leds::::on(1).map_err(|e| e.into()).flex_unwrap(); // red on dongle let mut storage = take_storage::().unwrap(); let num_pages = storage.num_pages(); let mut console = Console::::writer(); @@ -65,6 +66,6 @@ fn main() { } } writeln!(console, "Done.").unwrap(); - Leds::::on(1).unwrap(); - Leds::::off(0).unwrap(); // green on dongle + Leds::::on(1).map_err(|e| e.into()).flex_unwrap(); + Leds::::off(0).map_err(|e| e.into()).flex_unwrap(); // green on dongle }