diff --git a/CHANGELOG.md b/CHANGELOG.md index f33f4031c..2858be9a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - All traits have been marked as proven (`unproven` feature has been removed). - All trait methods have been made fallible. - All trait methods have been renamed `try_*` (i.e. `try_send`) for consistency. +- The minimum supported Rust version is 1.35 due to [this issue](https://github.com/rust-lang/rust/issues/54973). ## [v0.2.3] - 2019-05-09 diff --git a/src/adc.rs b/src/adc.rs index c39379565..293ad4d94 100644 --- a/src/adc.rs +++ b/src/adc.rs @@ -20,7 +20,7 @@ use nb; /// impl Channel for Gpio1Pin1 { /// type ID = u8; // ADC channels are identified numerically /// -/// fn channel() -> u8 { 7_u8 } // GPIO pin 1 is connected to ADC channel 7 +/// const CHANNEL: u8 = 7_u8; // GPIO pin 1 is connected to ADC channel 7 /// } /// /// struct Adc2; // ADC with two banks of 16 channels @@ -31,7 +31,7 @@ use nb; /// impl Channel for Gpio2PinA { /// type ID = (u8, u8); // ADC channels are identified by bank number and channel number /// -/// fn channel() -> (u8, u8) { (0, 3) } // bank 0 channel 3 +/// const CHANNEL: (u8, u8) = (0, 3); // bank 0 channel 3 /// } /// ``` pub trait Channel { @@ -44,12 +44,7 @@ pub trait Channel { /// Get the specific ID that identifies this channel, for example `0_u8` for the first ADC /// channel, if Self::ID is u8. - fn channel() -> Self::ID; - - // `channel` is a function due to [this reported - // issue](https://github.com/rust-lang/rust/issues/54973). Something about blanket impls - // combined with `type ID; const CHANNEL: Self::ID;` causes problems. - //const CHANNEL: Self::ID; + const CHANNEL: Self::ID; } /// ADCs that sample on single channels per request, and do so at the time of the request. @@ -75,7 +70,7 @@ pub trait Channel { /// type Error = (); /// /// fn try_read(&mut self, _pin: &mut PIN) -> nb::Result { -/// let chan = 1 << PIN::channel(); +/// let chan = 1 << PIN::CHANNEL; /// self.power_up(); /// let result = self.do_conversion(chan); /// self.power_down();