diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index b448f6ab6..a9df231e5 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -1,7 +1,7 @@ #![no_std] #![cfg_attr( feature = "nightly", - feature(generic_associated_types, type_alias_impl_trait) + feature(generic_associated_types, type_alias_impl_trait, slice_ptr_len) )] #[cfg(not(any( diff --git a/embassy-nrf/src/util.rs b/embassy-nrf/src/util.rs index b24bc452f..84848e872 100644 --- a/embassy-nrf/src/util.rs +++ b/embassy-nrf/src/util.rs @@ -19,10 +19,10 @@ pub(crate) fn slice_in_ram(slice: *const [T]) -> bool { ptr >= SRAM_LOWER && (ptr + len * core::mem::size_of::()) < SRAM_UPPER } -/// Return an error if slice is not in RAM. +/// Return an error if slice is not in RAM. Skips check if slice is zero-length. #[cfg(not(feature = "nrf51"))] pub(crate) fn slice_in_ram_or(slice: *const [T], err: E) -> Result<(), E> { - if slice_in_ram(slice) { + if slice.len() > 0 && slice_in_ram(slice) { Ok(()) } else { Err(err)