90
90
//! [`WouldBlock`]: https://docs.rs/nb/0.1.0/nb/enum.Error.html
91
91
//!
92
92
//! Some traits, like the one shown below, may expose possibly blocking APIs that can't fail. In
93
- //! those cases `nb::Result<_, Void >` is used.
93
+ //! those cases `nb::Result<_, Infallible >` is used.
94
94
//!
95
95
//! ```
96
96
//! extern crate nb;
97
- //! extern crate void;
98
97
//!
99
- //! use void::Void;
98
+ //! # use std as core;
99
+ //! use core::convert::Infallible;
100
100
//!
101
101
//! /// A count down timer
102
102
//! pub trait CountDown {
103
103
//! // ..
104
104
//!
105
105
//! /// "waits" until the count down is over
106
- //! fn wait(&mut self) -> nb::Result<(), Void >;
106
+ //! fn wait(&mut self) -> nb::Result<(), Infallible >;
107
107
//! }
108
108
//!
109
109
//! # fn main() {}
223
223
//! # }
224
224
//!
225
225
//! # mod stm32f30x_hal {
226
- //! # extern crate void;
227
- //! # use self::void::Void;
226
+ //! # use std::convert::Infallible;
228
227
//! # pub struct Serial1;
229
228
//! # impl Serial1 {
230
- //! # pub fn write(&mut self, _: u8) -> ::nb::Result<(), Void > {
229
+ //! # pub fn write(&mut self, _: u8) -> ::nb::Result<(), Infallible > {
231
230
//! # Ok(())
232
231
//! # }
233
232
//! # }
242
241
//! ```
243
242
//! extern crate embedded_hal as hal;
244
243
//! extern crate futures;
245
- //! extern crate void;
246
244
//!
247
245
//! #[macro_use(try_nb)]
248
246
//! extern crate nb;
255
253
//! };
256
254
//! use futures::future::Loop;
257
255
//! use stm32f30x_hal::{Led, Serial1, Timer6};
258
- //! use void::Void ;
256
+ //! use std::convert::Infallible ;
259
257
//!
260
258
//! /// `futures` version of `CountDown.wait`
261
259
//! ///
262
260
//! /// This returns a future that must be polled to completion
263
- //! fn wait<T>(mut timer: T) -> impl Future<Item = T, Error = Void >
261
+ //! fn wait<T>(mut timer: T) -> impl Future<Item = T, Error = Infallible >
264
262
//! where
265
263
//! T: hal::timer::CountDown,
266
264
//! {
342
340
//!
343
341
//! // Event loop
344
342
//! loop {
345
- //! blinky.poll().unwrap(); // NOTE(unwrap) E = Void
343
+ //! blinky.poll().unwrap(); // NOTE(unwrap) E = Infallible
346
344
//! loopback.poll().unwrap();
347
345
//! # break;
348
346
//! }
349
347
//! }
350
348
//!
351
349
//! # mod stm32f30x_hal {
352
- //! # extern crate void;
353
- //! # use self::void::Void;
350
+ //! # use std::convert::Infallible;
354
351
//! # pub struct Timer6;
355
352
//! # impl ::hal::timer::CountDown for Timer6 {
356
353
//! # type Time = ();
357
354
//! #
358
355
//! # fn start<T>(&mut self, _: T) where T: Into<()> {}
359
- //! # fn wait(&mut self) -> ::nb::Result<(), Void > { Err(::nb::Error::WouldBlock) }
356
+ //! # fn wait(&mut self) -> ::nb::Result<(), Infallible > { Err(::nb::Error::WouldBlock) }
360
357
//! # }
361
358
//! #
362
359
//! # pub struct Serial1;
363
360
//! # impl ::hal::serial::Read<u8> for Serial1 {
364
- //! # type Error = Void ;
365
- //! # fn read(&mut self) -> ::nb::Result<u8, Void > { Err(::nb::Error::WouldBlock) }
361
+ //! # type Error = Infallible ;
362
+ //! # fn read(&mut self) -> ::nb::Result<u8, Infallible > { Err(::nb::Error::WouldBlock) }
366
363
//! # }
367
364
//! # impl ::hal::serial::Write<u8> for Serial1 {
368
- //! # type Error = Void ;
369
- //! # fn flush(&mut self) -> ::nb::Result<(), Void > { Err(::nb::Error::WouldBlock) }
370
- //! # fn write(&mut self, _: u8) -> ::nb::Result<(), Void > { Err(::nb::Error::WouldBlock) }
365
+ //! # type Error = Infallible ;
366
+ //! # fn flush(&mut self) -> ::nb::Result<(), Infallible > { Err(::nb::Error::WouldBlock) }
367
+ //! # fn write(&mut self, _: u8) -> ::nb::Result<(), Infallible > { Err(::nb::Error::WouldBlock) }
371
368
//! # }
372
369
//! #
373
370
//! # pub struct Led;
418
415
//! loop {
419
416
//! // `await!` means "suspend / yield here" instead of "block until
420
417
//! // completion"
421
- //! await!(timer.wait()).unwrap(); // NOTE(unwrap) E = Void
418
+ //! await!(timer.wait()).unwrap(); // NOTE(unwrap) E = Infallible
422
419
//!
423
420
//! state = !state;
424
421
//!
446
443
//! }
447
444
//!
448
445
//! # mod stm32f30x_hal {
449
- //! # extern crate void;
450
- //! # use self::void::Void;
446
+ //! # use std::convert::Infallible;
451
447
//! # pub struct Serial1;
452
448
//! # impl Serial1 {
453
- //! # pub fn read(&mut self) -> ::nb::Result<u8, Void > { Err(::nb::Error::WouldBlock) }
454
- //! # pub fn write(&mut self, _: u8) -> ::nb::Result<(), Void > { Err(::nb::Error::WouldBlock) }
449
+ //! # pub fn read(&mut self) -> ::nb::Result<u8, Infallible > { Err(::nb::Error::WouldBlock) }
450
+ //! # pub fn write(&mut self, _: u8) -> ::nb::Result<(), Infallible > { Err(::nb::Error::WouldBlock) }
455
451
//! # }
456
452
//! # pub struct Timer6;
457
453
//! # impl Timer6 {
458
- //! # pub fn wait(&mut self) -> ::nb::Result<(), Void > { Err(::nb::Error::WouldBlock) }
454
+ //! # pub fn wait(&mut self) -> ::nb::Result<(), Infallible > { Err(::nb::Error::WouldBlock) }
459
455
//! # }
460
456
//! # pub struct Led;
461
457
//! # impl Led {
594
590
//! - Buffered serial interface with periodic flushing in interrupt handler
595
591
//!
596
592
//! ```
593
+ //! # use std as core;
597
594
//! extern crate embedded_hal as hal;
598
595
//! extern crate nb;
599
- //! extern crate void;
600
596
//!
601
597
//! use hal::prelude::*;
602
- //! use void::Void ;
598
+ //! use core::convert::Infallible ;
603
599
//!
604
600
//! fn flush<S>(serial: &mut S, cb: &mut CircularBuffer)
605
601
//! where
606
- //! S: hal::serial::Write<u8, Error = Void >,
602
+ //! S: hal::serial::Write<u8, Error = Infallible >,
607
603
//! {
608
604
//! loop {
609
605
//! if let Some(byte) = cb.peek() {
668
664
//! # }
669
665
//! # struct Serial1;
670
666
//! # impl ::hal::serial::Write<u8> for Serial1 {
671
- //! # type Error = Void ;
672
- //! # fn write(&mut self, _: u8) -> nb::Result<(), Void > { Err(::nb::Error::WouldBlock) }
673
- //! # fn flush(&mut self) -> nb::Result<(), Void > { Err(::nb::Error::WouldBlock) }
667
+ //! # type Error = Infallible ;
668
+ //! # fn write(&mut self, _: u8) -> nb::Result<(), Infallible > { Err(::nb::Error::WouldBlock) }
669
+ //! # fn flush(&mut self) -> nb::Result<(), Infallible > { Err(::nb::Error::WouldBlock) }
674
670
//! # }
675
671
//! # struct CircularBuffer;
676
672
//! # impl CircularBuffer {
687
683
688
684
#[ macro_use]
689
685
extern crate nb;
690
- extern crate void;
691
686
692
687
pub mod adc;
693
688
pub mod blocking;
@@ -731,8 +726,7 @@ pub mod watchdog;
731
726
/// println!("Period: {} ms", period);
732
727
/// }
733
728
///
734
- /// # extern crate void;
735
- /// # use void::Void;
729
+ /// # use std::convert::Infallible;
736
730
/// # struct MilliSeconds(u32);
737
731
/// # trait U32Ext { fn ms(self) -> MilliSeconds; }
738
732
/// # impl U32Ext for u32 { fn ms(self) -> MilliSeconds { MilliSeconds(self) } }
@@ -741,9 +735,9 @@ pub mod watchdog;
741
735
/// # impl hal::Capture for Capture1 {
742
736
/// # type Capture = u16;
743
737
/// # type Channel = Channel;
744
- /// # type Error = Void ;
738
+ /// # type Error = Infallible ;
745
739
/// # type Time = MilliSeconds;
746
- /// # fn capture(&mut self, _: Channel) -> ::nb::Result<u16, Void > { Ok(0) }
740
+ /// # fn capture(&mut self, _: Channel) -> ::nb::Result<u16, Infallible > { Ok(0) }
747
741
/// # fn disable(&mut self, _: Channel) { unimplemented!() }
748
742
/// # fn enable(&mut self, _: Channel) { unimplemented!() }
749
743
/// # fn get_resolution(&self) -> MilliSeconds { unimplemented!() }
@@ -948,8 +942,7 @@ pub trait PwmPin {
948
942
/// println!("Speed: {} pulses per second", speed);
949
943
/// }
950
944
///
951
- /// # extern crate void;
952
- /// # use void::Void;
945
+ /// # use std::convert::Infallible;
953
946
/// # struct Seconds(u32);
954
947
/// # trait U32Ext { fn s(self) -> Seconds; }
955
948
/// # impl U32Ext for u32 { fn s(self) -> Seconds { Seconds(self) } }
@@ -963,7 +956,7 @@ pub trait PwmPin {
963
956
/// # impl hal::timer::CountDown for Timer6 {
964
957
/// # type Time = Seconds;
965
958
/// # fn start<T>(&mut self, _: T) where T: Into<Seconds> {}
966
- /// # fn wait(&mut self) -> ::nb::Result<(), Void > { Ok(()) }
959
+ /// # fn wait(&mut self) -> ::nb::Result<(), Infallible > { Ok(()) }
967
960
/// # }
968
961
/// ```
969
962
#[ cfg( feature = "unproven" ) ]
0 commit comments