aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-08-28 21:28:26 +0200
committerDario Nieuwenhuis <[email protected]>2022-08-28 22:54:38 +0200
commit973f3b513fb85b7587312196d8f3aef75be2615f (patch)
treed2f64d91d6e3b625b99a16588aec8f1deeb99ef7
parent3763baf8fa4cf332a81214eb1610afdaf5173824 (diff)
futures: make `select_(slice|array)` hang intead of panicking if empty.
-rw-r--r--embassy-futures/src/select.rs10
1 files changed, 2 insertions, 8 deletions
diff --git a/embassy-futures/src/select.rs b/embassy-futures/src/select.rs
index facc2f60b..c0dd7ecd3 100644
--- a/embassy-futures/src/select.rs
+++ b/embassy-futures/src/select.rs
@@ -199,11 +199,8 @@ pub struct SelectArray<Fut, const N: usize> {
199/// completion the item resolved will be returned, along with the index of the 199/// completion the item resolved will be returned, along with the index of the
200/// future that was ready. 200/// future that was ready.
201/// 201///
202/// # Panics 202/// If the array is empty, the resulting future will be Pending forever.
203///
204/// This function will panic if the array specified contains no items.
205pub fn select_array<Fut: Future, const N: usize>(arr: [Fut; N]) -> SelectArray<Fut, N> { 203pub fn select_array<Fut: Future, const N: usize>(arr: [Fut; N]) -> SelectArray<Fut, N> {
206 assert!(N > 0);
207 SelectArray { inner: arr } 204 SelectArray { inner: arr }
208} 205}
209 206
@@ -247,11 +244,8 @@ pub struct SelectSlice<'a, Fut> {
247/// completion the item resolved will be returned, along with the index of the 244/// completion the item resolved will be returned, along with the index of the
248/// future that was ready. 245/// future that was ready.
249/// 246///
250/// # Panics 247/// If the slice is empty, the resulting future will be Pending forever.
251///
252/// This function will panic if the slice specified contains no items.
253pub fn select_slice<'a, Fut: Future>(slice: &'a mut [Fut]) -> SelectSlice<'a, Fut> { 248pub fn select_slice<'a, Fut: Future>(slice: &'a mut [Fut]) -> SelectSlice<'a, Fut> {
254 assert!(!slice.is_empty());
255 SelectSlice { inner: slice } 249 SelectSlice { inner: slice }
256} 250}
257 251