aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src/uarte.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-08-31 02:46:52 +0200
committerDario Nieuwenhuis <[email protected]>2022-08-31 03:11:21 +0200
commit8ba421f324f0971b2394f497d8fbbee65847f583 (patch)
tree81c4f1f6d62fdc85f17c466e26d8bb16198a7301 /embassy-nrf/src/uarte.rs
parentfe08bdf0d81e784c3af642128b91a53514b79a63 (diff)
Do not use cfg_if for embedded-hal-async feature gates.
Old code used `cfg_if!` because rustc still parses code inside disabled cfg's, and Rust stable at that time couldn't parse the new GAT where-clause location. This is not the case anymore.
Diffstat (limited to 'embassy-nrf/src/uarte.rs')
-rw-r--r--embassy-nrf/src/uarte.rs99
1 files changed, 50 insertions, 49 deletions
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs
index 4347ea558..c250e24ca 100644
--- a/embassy-nrf/src/uarte.rs
+++ b/embassy-nrf/src/uarte.rs
@@ -1073,78 +1073,79 @@ mod eh1 {
1073 } 1073 }
1074} 1074}
1075 1075
1076cfg_if::cfg_if! { 1076#[cfg(all(
1077 if #[cfg(all(feature = "unstable-traits", feature = "nightly", feature = "_todo_embedded_hal_serial"))] { 1077 feature = "unstable-traits",
1078 use core::future::Future; 1078 feature = "nightly",
1079 feature = "_todo_embedded_hal_serial"
1080))]
1081mod eha {
1082 use core::future::Future;
1079 1083
1080 impl<'d, T: Instance> embedded_hal_async::serial::Read for Uarte<'d, T> { 1084 use super::*;
1081 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
1082 1085
1083 fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { 1086 impl<'d, T: Instance> embedded_hal_async::serial::Read for Uarte<'d, T> {
1084 self.read(buffer) 1087 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
1085 } 1088
1089 fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> {
1090 self.read(buffer)
1086 } 1091 }
1092 }
1087 1093
1088 impl<'d, T: Instance> embedded_hal_async::serial::Write for Uarte<'d, T> { 1094 impl<'d, T: Instance> embedded_hal_async::serial::Write for Uarte<'d, T> {
1089 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 1095 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
1090 1096
1091 fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> { 1097 fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> {
1092 self.write(buffer) 1098 self.write(buffer)
1093 } 1099 }
1094 1100
1095 type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 1101 type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
1096 1102
1097 fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { 1103 fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> {
1098 async move { Ok(()) } 1104 async move { Ok(()) }
1099 }
1100 } 1105 }
1106 }
1101 1107
1102 impl<'d, T: Instance> embedded_hal_async::serial::Write for UarteTx<'d, T> { 1108 impl<'d, T: Instance> embedded_hal_async::serial::Write for UarteTx<'d, T> {
1103 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 1109 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
1104 1110
1105 fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> { 1111 fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> {
1106 self.write(buffer) 1112 self.write(buffer)
1107 } 1113 }
1108 1114
1109 type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 1115 type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
1110 1116
1111 fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { 1117 fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> {
1112 async move { Ok(()) } 1118 async move { Ok(()) }
1113 }
1114 } 1119 }
1120 }
1115 1121
1116 impl<'d, T: Instance> embedded_hal_async::serial::Read for UarteRx<'d, T> { 1122 impl<'d, T: Instance> embedded_hal_async::serial::Read for UarteRx<'d, T> {
1117 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 1123 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
1118 1124
1119 fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { 1125 fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> {
1120 self.read(buffer) 1126 self.read(buffer)
1121 }
1122 } 1127 }
1128 }
1123 1129
1124 impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Read 1130 impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Read for UarteWithIdle<'d, U, T> {
1125 for UarteWithIdle<'d, U, T> 1131 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
1126 {
1127 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
1128 1132
1129 fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { 1133 fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> {
1130 self.read(buffer) 1134 self.read(buffer)
1131 }
1132 } 1135 }
1136 }
1133 1137
1134 impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Write 1138 impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Write for UarteWithIdle<'d, U, T> {
1135 for UarteWithIdle<'d, U, T> 1139 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
1136 {
1137 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
1138 1140
1139 fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> { 1141 fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> {
1140 self.write(buffer) 1142 self.write(buffer)
1141 } 1143 }
1142 1144
1143 type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 1145 type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
1144 1146
1145 fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { 1147 fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> {
1146 async move { Ok(()) } 1148 async move { Ok(()) }
1147 }
1148 } 1149 }
1149 } 1150 }
1150} 1151}