From 6cb27ab120ca72d9fc85c8295273a7cf43ca375b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 14 Sep 2017 07:44:09 +0200 Subject: [PATCH] Improve `Mutex` example Fix some problems in the `Mutex` example. Please note that it still doesn't compile, as it's obviously rather abstract and incomplete, in order to demonstrate the principle. --- src/lib.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d89cf7f..2d3f72a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -190,16 +190,21 @@ //! implementation: //! //! ``` ignore +//! extern crate embedded_hal as hal; +//! extern crate nb; +//! //! /// A synchronized serial interface //! // NOTE This is a global singleton -//! pub struct Serial1; +//! pub struct Serial1(Mutex<..>); //! //! // NOTE private //! static USART1: Mutex<_> = Mutex::new(..); //! -//! impl hal::Serial for Serial { -//! fn read(&self) -> Result> { -//! hal::Serial::read(&Serial(USART1.lock())) +//! impl hal::serial::Read for Serial1 { +//! type Error = !; +//! +//! fn read(&self) -> Result> { +//! hal::serial::Read::read(&Serial1(USART1.lock())) //! } //! } //! ```