Skip to content

Commit facfe77

Browse files
bors[bot]Dirbaio
andauthored
Merge #282
282: Remove prelude. r=therealprof a=Dirbaio **DEPENDS on #280** Following discussions in #280 #281, we might want to use the same method names for the `blocking` and `nb` (and in the future, `futures`) trait flavors. In that case, importing the prelude guarantees naming conflicts, so it's better to remove it. An alternative would be splitting the prelude in `blocking` and `nb`. However, users often use blocking trait A and nonblocking trait B at the same time, so they'd end up importing both preludes and having name conflicts anyway. Co-authored-by: Dario Nieuwenhuis <[email protected]>
2 parents 0ab50cd + b6419e3 commit facfe77

File tree

7 files changed

+10
-48
lines changed

7 files changed

+10
-48
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1818
- Re-export `nb::{block!, Error, Result}` to avoid version mismatches. These should be used instead of
1919
importing the `nb` crate directly in dependendent crates.
2020
- `blocking::Serial`: renamed `bwrite_all` to `write`, `bflush` to `flush.
21+
- Removed `prelude` to avoid method name conflicts between different flavors (blocking, nb) of the same trait. Traits must now be manually imported.
2122

2223
## [v1.0.0-alpha.4] - 2020-11-11
2324

src/blocking/pwm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/// ```
1010
/// extern crate embedded_hal as hal;
1111
///
12-
/// use hal::prelude::*;
12+
/// use hal::blocking::pwm::Pwm;
1313
///
1414
/// fn main() {
1515
/// let mut pwm: Pwm1 = {

src/blocking/qei.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
/// #[macro_use(block)]
1212
/// extern crate nb;
1313
///
14-
/// use hal::prelude::*;
14+
/// use hal::blocking::qei::Qei;
15+
/// use hal::nb::timer::CountDown;
1516
///
1617
/// fn main() {
1718
/// let mut qei: Qei1 = {

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244
//! ```
245245
//! use embedded_hal as hal;
246246
//! use nb::block;
247-
//! use hal::prelude::*;
247+
//! use hal::nb::serial::Write;
248248
//!
249249
//! fn write_all<S>(serial: &mut S, buffer: &[u8]) -> Result<(), S::Error>
250250
//! where
@@ -266,7 +266,8 @@
266266
//! use embedded_hal as hal;
267267
//! use nb;
268268
//!
269-
//! use hal::prelude::*;
269+
//! use hal::nb::serial::Write;
270+
//! use hal::nb::timer::CountDown;
270271
//!
271272
//! enum Error<SE, TE> {
272273
//! /// Serial interface error
@@ -320,7 +321,7 @@
320321
//! use embedded_hal as hal;
321322
//! use nb;
322323
//!
323-
//! use hal::prelude::*;
324+
//! use hal::nb::serial::Write;
324325
//! use ::core::convert::Infallible;
325326
//!
326327
//! fn flush<S>(serial: &mut S, cb: &mut CircularBuffer)
@@ -411,7 +412,6 @@
411412
pub mod blocking;
412413
pub mod fmt;
413414
pub mod nb;
414-
pub mod prelude;
415415

416416
mod private {
417417
use crate::blocking::i2c::{SevenBitAddress, TenBitAddress};

src/nb/capture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/// #[macro_use(block)]
1313
/// extern crate nb;
1414
///
15-
/// use hal::prelude::*;
15+
/// use hal::nb::capture::Capture;
1616
///
1717
/// fn main() {
1818
/// let mut capture: Capture1 = {

src/nb/timer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/// #[macro_use(block)]
2020
/// extern crate nb;
2121
///
22-
/// use hal::prelude::*;
22+
/// use hal::nb::timer::CountDown;
2323
///
2424
/// fn main() {
2525
/// let mut led: Led = {

src/prelude.rs

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)