Skip to content

Commit

Permalink
futures: make select_(slice|array) hang intead of panicking if empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Aug 28, 2022
1 parent 3763baf commit 973f3b5
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions embassy-futures/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,8 @@ pub struct SelectArray<Fut, const N: usize> {
/// 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<Fut: Future, const N: usize>(arr: [Fut; N]) -> SelectArray<Fut, N> {
assert!(N > 0);
SelectArray { inner: arr }
}

Expand Down Expand Up @@ -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 }
}

Expand Down

0 comments on commit 973f3b5

Please sign in to comment.