diff --git a/power-policy-service/src/charger.rs b/power-policy-service/src/charger.rs index 98ddcca1..97a63088 100644 --- a/power-policy-service/src/charger.rs +++ b/power-policy-service/src/charger.rs @@ -35,7 +35,10 @@ where // Push will never fail since the number of receivers is the same as the capacity of the vector let _ = futures.push(async move { (receiver.wait_next().await, psu) }); } - select_slice(pin!(&mut futures)).await + // Pin the futures and deference to a slice + let pinned = pin!(futures); + // Safety: The backing buffer is contained within the heapless::Vec so it won't be moved either. + select_slice(unsafe { pinned.map_unchecked_mut(|f| f.as_mut()) }).await }; Event { charger, event } diff --git a/power-policy-service/src/psu.rs b/power-policy-service/src/psu.rs index 99b72cf6..e731ed06 100644 --- a/power-policy-service/src/psu.rs +++ b/power-policy-service/src/psu.rs @@ -32,7 +32,10 @@ where // Push will never fail since the number of receivers is the same as the capacity of the vector let _ = futures.push(async move { (receiver.wait_next().await, psu) }); } - select_slice(pin!(&mut futures)).await + // Pin the futures and deference to a slice + let pinned = pin!(futures); + // Safety: The backing buffer is contained within the heapless::Vec so it won't be moved either. + select_slice(unsafe { pinned.map_unchecked_mut(|f| f.as_mut()) }).await }; Event { psu, event } diff --git a/type-c-service/src/service/event_receiver.rs b/type-c-service/src/service/event_receiver.rs index b048fc9a..eb2e669b 100644 --- a/type-c-service/src/service/event_receiver.rs +++ b/type-c-service/src/service/event_receiver.rs @@ -42,7 +42,10 @@ impl< // Push will never fail since the number of receivers is the same as the capacity of the vector let _ = futures.push(async move { (receiver.wait_next().await, psu) }); } - select_slice(pin!(&mut futures)).await + // Pin the futures and deference to a slice + let pinned = pin!(futures); + // Safety: The backing buffer is contained within the heapless::Vec so it won't be moved either. + select_slice(unsafe { pinned.map_unchecked_mut(|f| f.as_mut()) }).await }; Event::PortEvent(PortEvent { port: *port, event })