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<_, ! >` is used.
93
+ //! those cases `nb::Result<_, Void >` is used.
94
94
//!
95
95
//! ```
96
- //! #![feature(never_type)]
97
- //!
98
96
//! extern crate nb;
97
+ //! extern crate void;
98
+ //!
99
+ //! use void::Void;
99
100
//!
100
101
//! /// A count down timer
101
102
//! pub trait CountDown {
102
103
//! // ..
103
104
//!
104
105
//! /// "waits" until the count down is over
105
- //! fn wait(&mut self) -> nb::Result<(), ! >;
106
+ //! fn wait(&mut self) -> nb::Result<(), Void >;
106
107
//! }
107
108
//!
108
109
//! # fn main() {}
201
202
//! fashion:
202
203
//!
203
204
//! ```
204
- //! # #![feature(never_type)]
205
205
//! extern crate embedded_hal;
206
206
//! #[macro_use(block)]
207
207
//! extern crate nb;
223
223
//! # }
224
224
//!
225
225
//! # mod stm32f30x_hal {
226
+ //! # extern crate void;
227
+ //! # use self::void::Void;
226
228
//! # pub struct Serial1;
227
229
//! # impl Serial1 {
228
- //! # pub fn write(&mut self, _: u8) -> ::nb::Result<(), ! > {
230
+ //! # pub fn write(&mut self, _: u8) -> ::nb::Result<(), Void > {
229
231
//! # Ok(())
230
232
//! # }
231
233
//! # }
238
240
//! second. Second task: loop back data over the serial interface.
239
241
//!
240
242
//! ```
241
- //! #![feature(conservative_impl_trait)]
242
- //! #![feature(never_type)]
243
- //!
244
243
//! extern crate embedded_hal as hal;
245
244
//! extern crate futures;
245
+ //! extern crate void;
246
246
//!
247
247
//! #[macro_use(try_nb)]
248
248
//! extern crate nb;
255
255
//! };
256
256
//! use futures::future::Loop;
257
257
//! use stm32f30x_hal::{Led, Serial1, Timer6};
258
+ //! use void::Void;
258
259
//!
259
260
//! /// `futures` version of `CountDown.wait`
260
261
//! ///
261
262
//! /// This returns a future that must be polled to completion
262
- //! fn wait<T>(mut timer: T) -> impl Future<Item = T, Error = ! >
263
+ //! fn wait<T>(mut timer: T) -> impl Future<Item = T, Error = Void >
263
264
//! where
264
265
//! T: hal::timer::CountDown,
265
266
//! {
341
342
//!
342
343
//! // Event loop
343
344
//! loop {
344
- //! blinky.poll().unwrap(); // NOTE(unwrap) E = !
345
+ //! blinky.poll().unwrap(); // NOTE(unwrap) E = Void
345
346
//! loopback.poll().unwrap();
346
347
//! # break;
347
348
//! }
348
349
//! }
349
350
//!
350
351
//! # mod stm32f30x_hal {
352
+ //! # extern crate void;
353
+ //! # use self::void::Void;
351
354
//! # pub struct Timer6;
352
355
//! # impl ::hal::timer::CountDown for Timer6 {
353
356
//! # type Time = ();
354
357
//! #
355
358
//! # fn start<T>(&mut self, _: T) where T: Into<()> {}
356
- //! # fn wait(&mut self) -> ::nb::Result<(), ! > { Err(::nb::Error::WouldBlock) }
359
+ //! # fn wait(&mut self) -> ::nb::Result<(), Void > { Err(::nb::Error::WouldBlock) }
357
360
//! # }
358
361
//! #
359
362
//! # pub struct Serial1;
360
363
//! # impl ::hal::serial::Read<u8> for Serial1 {
361
- //! # type Error = ! ;
362
- //! # fn read(&mut self) -> ::nb::Result<u8, ! > { Err(::nb::Error::WouldBlock) }
364
+ //! # type Error = Void ;
365
+ //! # fn read(&mut self) -> ::nb::Result<u8, Void > { Err(::nb::Error::WouldBlock) }
363
366
//! # }
364
367
//! # impl ::hal::serial::Write<u8> for Serial1 {
365
- //! # type Error = ! ;
366
- //! # fn flush(&mut self) -> ::nb::Result<(), ! > { Err(::nb::Error::WouldBlock) }
367
- //! # fn write(&mut self, _: u8) -> ::nb::Result<(), ! > { Err(::nb::Error::WouldBlock) }
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) }
368
371
//! # }
369
372
//! #
370
373
//! # pub struct Led;
382
385
//! ```
383
386
//! #![feature(generator_trait)]
384
387
//! #![feature(generators)]
385
- //! # #![feature(never_type)]
386
388
//!
387
389
//! extern crate embedded_hal as hal;
388
390
//!
415
417
//! loop {
416
418
//! // `await!` means "suspend / yield here" instead of "block until
417
419
//! // completion"
418
- //! await!(timer.wait()).unwrap(); // NOTE(unwrap) E = !
420
+ //! await!(timer.wait()).unwrap(); // NOTE(unwrap) E = Void
419
421
//!
420
422
//! state = !state;
421
423
//!
436
438
//!
437
439
//! // Event loop
438
440
//! loop {
439
- //! blinky.resume();
440
- //! loopback.resume();
441
+ //! unsafe { blinky.resume(); }
442
+ //! unsafe { loopback.resume(); }
441
443
//! # break;
442
444
//! }
443
445
//! }
444
446
//!
445
447
//! # mod stm32f30x_hal {
448
+ //! # extern crate void;
449
+ //! # use self::void::Void;
446
450
//! # pub struct Serial1;
447
451
//! # impl Serial1 {
448
- //! # pub fn read(&mut self) -> ::nb::Result<u8, ! > { Err(::nb::Error::WouldBlock) }
449
- //! # pub fn write(&mut self, _: u8) -> ::nb::Result<(), ! > { Err(::nb::Error::WouldBlock) }
452
+ //! # pub fn read(&mut self) -> ::nb::Result<u8, Void > { Err(::nb::Error::WouldBlock) }
453
+ //! # pub fn write(&mut self, _: u8) -> ::nb::Result<(), Void > { Err(::nb::Error::WouldBlock) }
450
454
//! # }
451
455
//! # pub struct Timer6;
452
456
//! # impl Timer6 {
453
- //! # pub fn wait(&mut self) -> ::nb::Result<(), ! > { Err(::nb::Error::WouldBlock) }
457
+ //! # pub fn wait(&mut self) -> ::nb::Result<(), Void > { Err(::nb::Error::WouldBlock) }
454
458
//! # }
455
459
//! # pub struct Led;
456
460
//! # impl Led {
589
593
//! - Buffered serial interface with periodic flushing in interrupt handler
590
594
//!
591
595
//! ```
592
- //! # #![feature(never_type)]
593
596
//! extern crate embedded_hal as hal;
594
597
//! extern crate nb;
598
+ //! extern crate void;
595
599
//!
596
600
//! use hal::prelude::*;
601
+ //! use void::Void;
597
602
//!
598
603
//! fn flush<S>(serial: &mut S, cb: &mut CircularBuffer)
599
604
//! where
600
- //! S: hal::serial::Write<u8, Error = ! >,
605
+ //! S: hal::serial::Write<u8, Error = Void >,
601
606
//! {
602
607
//! loop {
603
608
//! if let Some(byte) = cb.peek() {
662
667
//! # }
663
668
//! # struct Serial1;
664
669
//! # impl ::hal::serial::Write<u8> for Serial1 {
665
- //! # type Error = ! ;
666
- //! # fn write(&mut self, _: u8) -> nb::Result<(), ! > { Err(::nb::Error::WouldBlock) }
667
- //! # fn flush(&mut self) -> nb::Result<(), ! > { Err(::nb::Error::WouldBlock) }
670
+ //! # type Error = Void ;
671
+ //! # fn write(&mut self, _: u8) -> nb::Result<(), Void > { Err(::nb::Error::WouldBlock) }
672
+ //! # fn flush(&mut self) -> nb::Result<(), Void > { Err(::nb::Error::WouldBlock) }
668
673
//! # }
669
674
//! # struct CircularBuffer;
670
675
//! # impl CircularBuffer {
678
683
679
684
#![ deny( missing_docs) ]
680
685
#![ deny( warnings) ]
681
- #![ feature( never_type) ]
682
686
#![ no_std]
683
687
684
688
#[ macro_use]
685
689
extern crate nb;
690
+ extern crate void;
686
691
687
692
pub mod blocking;
688
693
pub mod digital;
@@ -699,8 +704,6 @@ pub mod timer;
699
704
/// / events
700
705
///
701
706
/// ```
702
- /// # #![feature(never_type)]
703
- ///
704
707
/// extern crate embedded_hal as hal;
705
708
/// #[macro_use(block)]
706
709
/// extern crate nb;
@@ -723,6 +726,8 @@ pub mod timer;
723
726
/// println!("Period: {} ms", period);
724
727
/// }
725
728
///
729
+ /// # extern crate void;
730
+ /// # use void::Void;
726
731
/// # struct MilliSeconds(u32);
727
732
/// # trait U32Ext { fn ms(self) -> MilliSeconds; }
728
733
/// # impl U32Ext for u32 { fn ms(self) -> MilliSeconds { MilliSeconds(self) } }
@@ -731,9 +736,9 @@ pub mod timer;
731
736
/// # impl hal::Capture for Capture1 {
732
737
/// # type Capture = u16;
733
738
/// # type Channel = Channel;
734
- /// # type Error = ! ;
739
+ /// # type Error = Void ;
735
740
/// # type Time = MilliSeconds;
736
- /// # fn capture(&mut self, _: Channel) -> ::nb::Result<u16, ! > { Ok(0) }
741
+ /// # fn capture(&mut self, _: Channel) -> ::nb::Result<u16, Void > { Ok(0) }
737
742
/// # fn disable(&mut self, _: Channel) { unimplemented!() }
738
743
/// # fn enable(&mut self, _: Channel) { unimplemented!() }
739
744
/// # fn get_resolution(&self) -> MilliSeconds { unimplemented!() }
@@ -908,7 +913,6 @@ pub trait PwmPin {
908
913
/// You can use this interface to measure the speed of a motor
909
914
///
910
915
/// ```
911
- /// # #![feature(never_type)]
912
916
/// extern crate embedded_hal as hal;
913
917
/// #[macro_use(block)]
914
918
/// extern crate nb;
@@ -935,6 +939,8 @@ pub trait PwmPin {
935
939
/// println!("Speed: {} pulses per second", speed);
936
940
/// }
937
941
///
942
+ /// # extern crate void;
943
+ /// # use void::Void;
938
944
/// # struct Seconds(u32);
939
945
/// # trait U32Ext { fn s(self) -> Seconds; }
940
946
/// # impl U32Ext for u32 { fn s(self) -> Seconds { Seconds(self) } }
@@ -948,7 +954,7 @@ pub trait PwmPin {
948
954
/// # impl hal::timer::CountDown for Timer6 {
949
955
/// # type Time = Seconds;
950
956
/// # fn start<T>(&mut self, _: T) where T: Into<Seconds> {}
951
- /// # fn wait(&mut self) -> ::nb::Result<(), ! > { Ok(()) }
957
+ /// # fn wait(&mut self) -> ::nb::Result<(), Void > { Ok(()) }
952
958
/// # }
953
959
/// ```
954
960
#[ cfg( feature = "unproven" ) ]
0 commit comments