From c6989dfbca51787146f50270c671af9db434f577 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 29 Nov 2023 17:23:48 +0100 Subject: Remove nightly and unstable-traits features in preparation for 1.75. --- embassy-sync/src/lib.rs | 5 ++- embassy-sync/src/pipe.rs | 104 ++++++++++++++++++++++------------------------- 2 files changed, 52 insertions(+), 57 deletions(-) (limited to 'embassy-sync/src') diff --git a/embassy-sync/src/lib.rs b/embassy-sync/src/lib.rs index 3ffcb9135..b0ccfde57 100644 --- a/embassy-sync/src/lib.rs +++ b/embassy-sync/src/lib.rs @@ -1,6 +1,7 @@ #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] -#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))] -#![cfg_attr(feature = "nightly", allow(stable_features, unknown_lints, async_fn_in_trait))] +#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))] +#![cfg_attr(nightly, allow(stable_features, unknown_lints))] +#![allow(async_fn_in_trait)] #![allow(clippy::new_without_default)] #![doc = include_str!("../README.md")] #![warn(missing_docs)] diff --git a/embassy-sync/src/pipe.rs b/embassy-sync/src/pipe.rs index ec0cbbf2a..42fe8ebd0 100644 --- a/embassy-sync/src/pipe.rs +++ b/embassy-sync/src/pipe.rs @@ -1,6 +1,7 @@ //! Async byte stream pipe. use core::cell::{RefCell, UnsafeCell}; +use core::convert::Infallible; use core::future::Future; use core::ops::Range; use core::pin::Pin; @@ -457,84 +458,77 @@ where } } -#[cfg(feature = "nightly")] -mod io_impls { - use core::convert::Infallible; +impl embedded_io_async::ErrorType for Pipe { + type Error = Infallible; +} - use super::*; +impl embedded_io_async::Read for Pipe { + async fn read(&mut self, buf: &mut [u8]) -> Result { + Ok(Pipe::read(self, buf).await) + } +} - impl embedded_io_async::ErrorType for Pipe { - type Error = Infallible; +impl embedded_io_async::Write for Pipe { + async fn write(&mut self, buf: &[u8]) -> Result { + Ok(Pipe::write(self, buf).await) } - impl embedded_io_async::Read for Pipe { - async fn read(&mut self, buf: &mut [u8]) -> Result { - Ok(Pipe::read(self, buf).await) - } + async fn flush(&mut self) -> Result<(), Self::Error> { + Ok(()) } +} - impl embedded_io_async::Write for Pipe { - async fn write(&mut self, buf: &[u8]) -> Result { - Ok(Pipe::write(self, buf).await) - } +impl embedded_io_async::ErrorType for &Pipe { + type Error = Infallible; +} - async fn flush(&mut self) -> Result<(), Self::Error> { - Ok(()) - } +impl embedded_io_async::Read for &Pipe { + async fn read(&mut self, buf: &mut [u8]) -> Result { + Ok(Pipe::read(self, buf).await) } +} - impl embedded_io_async::ErrorType for &Pipe { - type Error = Infallible; +impl embedded_io_async::Write for &Pipe { + async fn write(&mut self, buf: &[u8]) -> Result { + Ok(Pipe::write(self, buf).await) } - impl embedded_io_async::Read for &Pipe { - async fn read(&mut self, buf: &mut [u8]) -> Result { - Ok(Pipe::read(self, buf).await) - } + async fn flush(&mut self) -> Result<(), Self::Error> { + Ok(()) } +} - impl embedded_io_async::Write for &Pipe { - async fn write(&mut self, buf: &[u8]) -> Result { - Ok(Pipe::write(self, buf).await) - } +impl embedded_io_async::ErrorType for Reader<'_, M, N> { + type Error = Infallible; +} - async fn flush(&mut self) -> Result<(), Self::Error> { - Ok(()) - } +impl embedded_io_async::Read for Reader<'_, M, N> { + async fn read(&mut self, buf: &mut [u8]) -> Result { + Ok(Reader::read(self, buf).await) } +} - impl embedded_io_async::ErrorType for Reader<'_, M, N> { - type Error = Infallible; +impl embedded_io_async::BufRead for Reader<'_, M, N> { + async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { + Ok(Reader::fill_buf(self).await) } - impl embedded_io_async::Read for Reader<'_, M, N> { - async fn read(&mut self, buf: &mut [u8]) -> Result { - Ok(Reader::read(self, buf).await) - } + fn consume(&mut self, amt: usize) { + Reader::consume(self, amt) } +} - impl embedded_io_async::BufRead for Reader<'_, M, N> { - async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { - Ok(Reader::fill_buf(self).await) - } - - fn consume(&mut self, amt: usize) { - Reader::consume(self, amt) - } - } +impl embedded_io_async::ErrorType for Writer<'_, M, N> { + type Error = Infallible; +} - impl embedded_io_async::ErrorType for Writer<'_, M, N> { - type Error = Infallible; +impl embedded_io_async::Write for Writer<'_, M, N> { + async fn write(&mut self, buf: &[u8]) -> Result { + Ok(Writer::write(self, buf).await) } - impl embedded_io_async::Write for Writer<'_, M, N> { - async fn write(&mut self, buf: &[u8]) -> Result { - Ok(Writer::write(self, buf).await) - } - - async fn flush(&mut self) -> Result<(), Self::Error> { - Ok(()) - } + async fn flush(&mut self) -> Result<(), Self::Error> { + Ok(()) } } -- cgit