From 973f3b513fb85b7587312196d8f3aef75be2615f Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sun, 28 Aug 2022 21:28:26 +0200 Subject: [PATCH] futures: make `select_(slice|array)` hang intead of panicking if empty. --- embassy-futures/src/select.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/embassy-futures/src/select.rs b/embassy-futures/src/select.rs index facc2f60..c0dd7ecd 100644 --- a/embassy-futures/src/select.rs +++ b/embassy-futures/src/select.rs @@ -199,11 +199,8 @@ pub struct SelectArray { /// completion the item resolved will be returned, along with the index of the /// future that was ready. /// -/// # Panics -/// -/// This function will panic if the array specified contains no items. +/// If the array is empty, the resulting future will be Pending forever. pub fn select_array(arr: [Fut; N]) -> SelectArray { - assert!(N > 0); SelectArray { inner: arr } } @@ -247,11 +244,8 @@ pub struct SelectSlice<'a, Fut> { /// completion the item resolved will be returned, along with the index of the /// future that was ready. /// -/// # Panics -/// -/// This function will panic if the slice specified contains no items. +/// If the slice is empty, the resulting future will be Pending forever. pub fn select_slice<'a, Fut: Future>(slice: &'a mut [Fut]) -> SelectSlice<'a, Fut> { - assert!(!slice.is_empty()); SelectSlice { inner: slice } }