aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTil Blechschmidt <[email protected]>2022-02-23 23:30:50 +0100
committerTil Blechschmidt <[email protected]>2022-02-23 23:30:50 +0100
commit6dc58645d22ebebf6abe8d4d07bcc3001cac91c6 (patch)
tree3021038bd3cc5b4ad337e5d0a84d607e2c9c324a
parent66fdec7abe649cb7d7203af526035e2a64a55776 (diff)
Change slice length check to use stable method
-rw-r--r--embassy-nrf/src/lib.rs2
-rw-r--r--embassy-nrf/src/util.rs3
2 files changed, 3 insertions, 2 deletions
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs
index a9df231e5..b448f6ab6 100644
--- a/embassy-nrf/src/lib.rs
+++ b/embassy-nrf/src/lib.rs
@@ -1,7 +1,7 @@
1#![no_std] 1#![no_std]
2#![cfg_attr( 2#![cfg_attr(
3 feature = "nightly", 3 feature = "nightly",
4 feature(generic_associated_types, type_alias_impl_trait, slice_ptr_len) 4 feature(generic_associated_types, type_alias_impl_trait)
5)] 5)]
6 6
7#[cfg(not(any( 7#[cfg(not(any(
diff --git a/embassy-nrf/src/util.rs b/embassy-nrf/src/util.rs
index 84848e872..42265dc20 100644
--- a/embassy-nrf/src/util.rs
+++ b/embassy-nrf/src/util.rs
@@ -22,7 +22,8 @@ pub(crate) fn slice_in_ram<T>(slice: *const [T]) -> bool {
22/// Return an error if slice is not in RAM. Skips check if slice is zero-length. 22/// Return an error if slice is not in RAM. Skips check if slice is zero-length.
23#[cfg(not(feature = "nrf51"))] 23#[cfg(not(feature = "nrf51"))]
24pub(crate) fn slice_in_ram_or<T, E>(slice: *const [T], err: E) -> Result<(), E> { 24pub(crate) fn slice_in_ram_or<T, E>(slice: *const [T], err: E) -> Result<(), E> {
25 if slice.len() > 0 && slice_in_ram(slice) { 25 let (_, len) = slice_ptr_parts(slice);
26 if len > 0 && slice_in_ram(slice) {
26 Ok(()) 27 Ok(())
27 } else { 28 } else {
28 Err(err) 29 Err(err)