Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove prelude. #282

Merged
merged 4 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Moved all traits into two modules depending on the execution model: `blocking` and `nb` (non-blocking).
- Re-export `nb::{block!, Error, Result}` to avoid version mismatches. These should be used instead of
importing the `nb` crate directly in dependendent crates.
- `blocking::Serial`: renamed `bwrite_all` to `write`, `bflush` to `flush.
- Removed `prelude` to avoid method name conflicts between different flavors (blocking, nb) of the same trait. Traits must now be manually imported.

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

Expand Down
2 changes: 1 addition & 1 deletion src/blocking/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// ```
/// extern crate embedded_hal as hal;
///
/// use hal::prelude::*;
/// use hal::blocking::pwm::Pwm;
///
/// fn main() {
/// let mut pwm: Pwm1 = {
Expand Down
3 changes: 2 additions & 1 deletion src/blocking/qei.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
/// #[macro_use(block)]
/// extern crate nb;
///
/// use hal::prelude::*;
/// use hal::blocking::qei::Qei;
/// use hal::nb::timer::CountDown;
///
/// fn main() {
/// let mut qei: Qei1 = {
Expand Down
12 changes: 6 additions & 6 deletions src/blocking/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ pub trait Write<Word> {
/// An implementation can choose to buffer the write, returning `Ok(())`
/// after the complete slice has been written to a buffer, but before all
/// words have been sent via the serial interface. To make sure that
/// everything has been sent, call [`bflush`] after this function returns.
/// everything has been sent, call [`flush`] after this function returns.
///
/// [`bflush`]: #tymethod.bflush
fn bwrite_all(&mut self, buffer: &[Word]) -> Result<(), Self::Error>;
/// [`flush`]: #tymethod.flush
fn write(&mut self, buffer: &[Word]) -> Result<(), Self::Error>;

/// Block until the serial interface has sent all buffered words
fn bflush(&mut self) -> Result<(), Self::Error>;
fn flush(&mut self) -> Result<(), Self::Error>;
}

/// Blocking serial write
Expand All @@ -38,15 +38,15 @@ pub mod write {
{
type Error = S::Error;

fn bwrite_all(&mut self, buffer: &[Word]) -> Result<(), Self::Error> {
fn write(&mut self, buffer: &[Word]) -> Result<(), Self::Error> {
for word in buffer {
nb::block!(self.write(word.clone()))?;
}

Ok(())
}

fn bflush(&mut self) -> Result<(), Self::Error> {
fn flush(&mut self) -> Result<(), Self::Error> {
nb::block!(self.flush())?;
Ok(())
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
//! ```
//! use embedded_hal as hal;
//! use nb::block;
//! use hal::prelude::*;
//! use hal::nb::serial::Write;
//!
//! fn write_all<S>(serial: &mut S, buffer: &[u8]) -> Result<(), S::Error>
//! where
Expand All @@ -266,7 +266,8 @@
//! use embedded_hal as hal;
//! use nb;
//!
//! use hal::prelude::*;
//! use hal::nb::serial::Write;
//! use hal::nb::timer::CountDown;
//!
//! enum Error<SE, TE> {
//! /// Serial interface error
Expand Down Expand Up @@ -320,7 +321,7 @@
//! use embedded_hal as hal;
//! use nb;
//!
//! use hal::prelude::*;
//! use hal::nb::serial::Write;
//! use ::core::convert::Infallible;
//!
//! fn flush<S>(serial: &mut S, cb: &mut CircularBuffer)
Expand Down Expand Up @@ -411,7 +412,6 @@
pub mod blocking;
pub mod fmt;
pub mod nb;
pub mod prelude;

mod private {
use crate::blocking::i2c::{SevenBitAddress, TenBitAddress};
Expand Down
2 changes: 1 addition & 1 deletion src/nb/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/// #[macro_use(block)]
/// extern crate nb;
///
/// use hal::prelude::*;
/// use hal::nb::capture::Capture;
///
/// fn main() {
/// let mut capture: Capture1 = {
Expand Down
2 changes: 1 addition & 1 deletion src/nb/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/// #[macro_use(block)]
/// extern crate nb;
///
/// use hal::prelude::*;
/// use hal::nb::timer::CountDown;
///
/// fn main() {
/// let mut led: Led = {
Expand Down
40 changes: 0 additions & 40 deletions src/prelude.rs

This file was deleted.